Forum Discussion
Cumulative Sum
Hi,
I have three main measures in my data model:
sales = DISTINCTCOUNT(Sales[Product ID])
Here find attached the Power BI model. https://drive.google.com/file/d/1izQnlhw_geZtn4bfe5T-by3BB__mbwFK/view?usp=sharing
Thank you in advance for your help!
Best,
Sara
Try this measure:
cum_conv = VAR vCurrentMonth = MAX ( 'Calendar'[Month Number] ) VAR vTable = ADDCOLUMNS ( ALLSELECTED ( 'Calendar'[Month Number] ), "@conv", [conv] ) VAR vResult = SUMX ( vTable, IF ( 'Calendar'[Month Number] <= vCurrentMonth, [@conv] ) ) RETURN vResult
4 Replies
- DataInsightsSuper User
I wasn't able to access the pbix via the link. This is the basic pattern for a cumulative sum:
cum_conv = CALCULATE ( [conv], FILTER ( ALL ( 'Calendar' ), 'Calendar'[Month Number] <= MAX ( 'Calendar'[Month Number] ) ) )- uscmeaFrequent Visitor
Hi DataInsights,
Thank you very much for your answer!
I tried before this formula, but for some reason, it is not working.
I also tried SUMX = (FILTER (ALL('Calendar'),'Calendar'[Month Number] <=MAX('Calendar'[Month Number]), [conv])), but I still do not obtain the desired result.
I shared the Power BI model via Drive, let me know if you can download it from there.
Best regards,Sara
- DataInsightsSuper User
Try this measure:
cum_conv = VAR vCurrentMonth = MAX ( 'Calendar'[Month Number] ) VAR vTable = ADDCOLUMNS ( ALLSELECTED ( 'Calendar'[Month Number] ), "@conv", [conv] ) VAR vResult = SUMX ( vTable, IF ( 'Calendar'[Month Number] <= vCurrentMonth, [@conv] ) ) RETURN vResult