How to SUM between a Date Range?

Stimulsoft Reports.JS discussion
Post Reply
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

How to SUM between a Date Range?

Post by ericp »

Please see the screenshot. I have a table with years associated to values. I want to separate the SUM of 'All Years' vs 'Active Years'. For example if I say my 'Active Years 'are between 2020 and 2024, how can create the formula to ignore the values with the Year 2019?
Attachments
Screen Shot 2023-09-05 at 3.02.14 PM.png
Screen Shot 2023-09-05 at 3.02.14 PM.png (197.03 KiB) Viewed 6803 times
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: How to SUM between a Date Range?

Post by Lech Kulikowski »

Hello,

Please try to use the SumIf() function. Something like:
SumIf(datasource.column, (datecolumn >= 2020 && datecolumn <= 2024))

Thank you.
ericp
Posts: 41
Joined: Mon Aug 21, 2023 9:22 pm

Re: How to SUM between a Date Range?

Post by ericp »

So this is the function I tried (in the Total column) and it doesn't seem to be working:

{SumIf(currentProjectRevision_ProjectRevisionFunding.Total), >=(currentProjectRevision.FiscalyearStart) && <=(currentProjectRevision.FiscalYearEnd)}

My datasource:
currentProjectRevision.FiscalyearStart = "2020"
currentProjectRevision.FiscalYearEnd = "2024"
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: How to SUM between a Date Range?

Post by Lech Kulikowski »

Hello,

Your expression is not correct, should be:
{SumIf(currentProjectRevision_ProjectRevisionFunding.Total, (YOURDATACOLUMN >=currentProjectRevision.FiscalyearStart && YOURDATACOLUMN <= currentProjectRevision.FiscalYearEnd))}

Thank you.
Post Reply