Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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.
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])))
Now, I also want to calculate the cumulative count for the last three months and display it as follows:
(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
@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
User | Count |
---|---|
81 | |
75 | |
74 | |
42 | |
36 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |