Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
dgdgdg122db
Helper II
Helper II

Cumulative last 3 months count base on different date

I would like to calculate the cumulative totals for the last three months based on different dates. In my fact table, I have the following columns: order date, customer ID, first login date, and first order date. There is a many-to-one relationship between the order date and the date table.

dgdgdg122db_2-1688719758199.png

 


In Power BI, I have created a table where the rows represent the end-of-month first login dates from the fact table, and the columns are based on the year month field from the date table. The values are the cumulative count
I calculated the customer count using the following DAX formula and created a table visual in Power BI:
CustomerCount =
CALCULATE(DISTINCTCOUNT(Orders[CustomerID]), FILTER(Orders, Orders[First login date (EOM)] <= Orders[First order date (EOM)]))
CumulativeCount =
CALCULATE([CustomerCount],FILTER(ALLSELECTED(Dates[Date]),Dates[Date]<=MAX(Dates[Date])))

dgdgdg122db_1-1688719737809.png

 



Now, I also want to calculate the cumulative count for the last three months and display it as follows:

dgdgdg122db_0-1688719722357.png

 


(the 160 in october would be = 65+50+45, Oct-Aug)
If there is any more info needed, please let me know, thanks for your help

1 REPLY 1
amitchandak
Super User
Super User

@dgdgdg122db , Create a date table join with all dates. one join will be active another one will be inactive

 

For active join have measures like

M1= DISTINCTCOUNT(Orders[CustomerID])

 

for Inactive date have measures like

m2 = calculate( DISTINCTCOUNT(Orders[CustomerID]), userelationship(Date[Date],Orders[First login date (EOM)]))

 

 

Now create rolling like

 

Rolling 3 = CALCULATE([M1],DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,MONTH))

 

Rolling 3 = CALCULATE([M2],DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,MONTH))

 

or

 

Rolling 3= CALCULATE([M1], WINDOW(-2,REL, 0, REL, ADDCOLUMNS(ALLSELECTED('Date'[Month Year],'Date'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))

 

or cumulative

 

Cumm Sales = CALCULATE([M2],filter(all('Date'),'Date'[date] <=max('Date'[date])))

Cumm Sales = CALCULATE([M2],filter(allselected(date),date[date] <=max(date[Date])))

 

Running Total/ Cumulative:
https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=42

Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors