Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
KKumar92
Contributor III
Contributor III

Calculation of Total Sum Between two Date Range

Hi All,

I am working on a report, where I want to calculate the Sum of Quantity for a given date range. And I have used the following expression for the measure.

Sum({$<DATE = {'>=$(=$(vMiDate))<=$(=$(vPrDate))'}>}QTY_ONHAND)

However, I am getting the answer as zero. Please advise how this could be rectified.

Variables;

vMiDate = Min(Total DATE)

vPrDate = Date((Max(DATE) - 1), 'DD/MM/YYYY')

Expected Output;

DATEQTYvMiDatevPrDateSUM
31/01/202110031/01/202130/01/2021100
1/2/20212531/01/202131/01/2021100
2/2/20215031/01/20211/2/2021125
3/2/20212531/01/20212/2/2021175
Labels (3)
1 Solution

Accepted Solutions
MayilVahanan

Hi @KKumar92 

When u are using Date field as Dimension, ur expression gives zero, because the date range is less than the date values. 

In order to achieve the expected result, might be try like below

If(RowNo(TOTAL)=1, Sum(QTY), RangeSum(Above(Sum(QTY), 0, RowNo(TOTAL)))-Sum(QTY))

MayilVahanan_0-1613983133561.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

10 Replies
agigliotti
Partner - Champion
Partner - Champion

Hi @KKumar92 ,

Maybe this:

=Sum( {< DATE = {">=$(vMiDate)<=$(vPrDate)"} >} QTY_ONHAND )

I hope it can help.

Best Regards

KKumar92
Contributor III
Contributor III
Author

Hi Agigliotti,

I tried the above formula, but again I am getting the answer "0" for the sum.

Thanks.

agigliotti
Partner - Champion
Partner - Champion

Hi,

May be there are problems with vMiDate and/or vPrDate date formatting...
What do you get with the below expression:
=Sum( {< DATE = {">=31/01/2021<=02/02/2021"} >} QTY_ONHAND )

?

KKumar92
Contributor III
Contributor III
Author

This expression return value 0.

Please check below for my variable declaration;

vMiDate = Min(Total DATE)

vPrDate = Date((Max(DATE) - 1), 'DD/MM/YYYY')

 

agigliotti
Partner - Champion
Partner - Champion

Let's put both variables in a text box to check if they are correctly formatted.
Also check your DATE field type and format.
What do you get?

KKumar92
Contributor III
Contributor III
Author

KKumar92_0-1613983005891.png

Please check above for the output.

MayilVahanan

Hi @KKumar92 

When u are using Date field as Dimension, ur expression gives zero, because the date range is less than the date values. 

In order to achieve the expected result, might be try like below

If(RowNo(TOTAL)=1, Sum(QTY), RangeSum(Above(Sum(QTY), 0, RowNo(TOTAL)))-Sum(QTY))

MayilVahanan_0-1613983133561.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
KKumar92
Contributor III
Contributor III
Author

Hi MayilVahanan,

Thanks for the solution above, I am getting the values now.

If I rephrase the above question is following way,

Where I want to calculate the Sum Between vMiDate and vPrDate, also I want to add the stock value of Current Date (Max Date).

Example, to calculate the stock  at '2/2/2021', I will take summation of following variables;

vMiDate  = 31/01/2021

vPrDate = 1/2/2021

vMaxDate = 2/2/2021

Please advise how this could be achieved through the formula you have stated above.

Thanks

MayilVahanan

HI @KKumar92 

You can add set analysis (date filter) in the Sum(QTY) formula in order to achieve the result.

Make sure, all the date & variables are in same format.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.