Forum Discussion
How to make a cumulative total for a second date column
I have a data set that has two date columns, a delivery date and a sale date. As delivery date is the column we refer to most often it is the one with an active relationship to my date table, and I have been able to create a cumulative measure for this easily enough
Cumulative Delivery Items = CALCULATE([Filtered Items],FILTER(ALL(Sales),Sales[Delivery Date]<= MAX(Sales[Delivery Date])))
Cumulative Sales Items = CALCULATE([Filtered Items],FILTER(ALL(Sales),Sales[Date Confirmed]<= MAX(Sales[Date Confirmed])),USERELATIONSHIP('Date Table'[Date],Sales[Date Confirmed]))
bisted , Try using below measure
Cumulative Sales Items =
CALCULATE(
[Filtered Items],
FILTER(
ALL(Sales),
Sales[Date Confirmed] <= MAX(Sales[Date Confirmed])
),
USERELATIONSHIP('Date Table'[Date], Sales[Date Confirmed])
)
4 Replies
- bhanu_gautam
Super User
bisted , Try using below measure
Cumulative Sales Items =
CALCULATE(
[Filtered Items],
FILTER(
ALL(Sales),
Sales[Date Confirmed] <= MAX(Sales[Date Confirmed])
),
USERELATIONSHIP('Date Table'[Date], Sales[Date Confirmed])
)- bistedFrequent Visitor
Hi bhanu_gautam, thank you for looking into this, unfortunately that just re-writes the above measure that I had tried, which doesn't work (I have tried it with your new formatting though in case it as an odd error related to that, but still no luck).
- bistedFrequent Visitor
Just to add, bhanu_gautam's approach works perfectly, it was my mistake of making a relationship between a date column in my date table that was whole dates with a date column that I hadn't noticed also contained times, adding a calculated column with rounded dates to use the relationship on worked fine.
Thank you bhanu_gautam!
- AnonymousNot applicable
Hi,
Thanks for the solution bhanu_gautam provided, and i want to offer some more informtion for user to refer to.
hello bisted , you can try the following solutions.
Sales Items = CALCULATE ( [Filtered Items], USERELATIONSHIP ( 'Date Table'[Date], Sales[Date Confirmed] ) )Then create a new measure
Cumulative Sales Items = IF ( [Sales Items] <> BLANK (), SUMX ( FILTER ( ALLSELECTED ( 'Date Table' ), [Date] <= MAX ( 'Date Table'[Date] ) ), [Sales Items] ) )Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.