简体   繁体   中英

ssrs skipping date parameter for an expression

I am creating a report in ssrs which calculates and compares different values for each customer. I have set two date parameters using memrepay.pday , FROM and TO.

eg we want all purchases (=SUM(Field!memrepay.mprinc.Value) by "Customer-1" FROM: 5/1/2015 TO: 5/31/2015 (easy enough). But also, all the purchases done from the beginning of his membership up TO:5/31/2015 in another cell, which is the same (=SUM(Field!memrepay.mprinc.Value) .

Is it possible to skip the selected "FROM" date for this expression and allow the expression to sum all paid amounts, from beginning, up to selected "TO" parameter?

`SELECT
  memrepay.lnr
  ,memrepay.pday
  ,memrepay.tcode
  ,memdues.dday
  ,memrepay.mprinc AS [memrepay mprinc]
  ,memrepay.mint AS [memrepay mint]
  ,memdues.mprinc AS [memdues mprinc]
  ,memdues.mint AS [memdues mint]

FROM
  memdues
  INNER JOIN memrepay
    ON memdues.lnr = memrepay.lnr AND memdues.memid = memrepay.memid
  INNER JOIN loan
    ON loan.lnr = memrepay.lnr AND loan.memid = memrepay.memid
WHERE
  memdues.dday >= @dday
  AND memdues.dday <= @dday2
  AND memrepay.pday >= @pday
  AND memrepay.pday <= @pday2`

You can get all the data back in your query and then filter using your To Date parameter like:

=SUM(IIF(FIELDS!YourDateField.VALUE <= Parameters!ToDate.Value  ,Field!paidamount.Value, 0))

Or between both dates:

=SUM(IIF(FIELDS!YourDateField.VALUE <= Parameters!ToDate.Value AND FIELDS!YourDateField.VALUE >= Parameters!FromDate.Value,Field!paidamount.Value, 0))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM