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.
Hey guys,
I need some direction on how to set up a tricky variation of distinct count by date. I have a long fact table with 10 years of data. Basically it looks like so:
CustomerId | VisitDate | VisitId |
SomeNumber | SomeDate | SomeOtherNumber |
... | ... | ... |
I need to display the distinct count of customers by month in a column chart. Simple enough. BUT, I need each month to include the distinct count of customerid in the trailing 12 months. So for example January would be distinct count of customers from 1/1/19-1/1/20, Febuary would be 2/1/19-2/1/20. AND, to make it more tricky, ideally you would be able to drill down to the day in the date heirarchy and each day on the chart be it's own 12 month period. (March 3 = 3/3/19-3/3/20, March 4 = 3/4/19-3/4/20).
Hope that makes sense.
Any ideas on how I would set this up?
Thanks!
Solved! Go to Solution.
@dedelman_clng I have it working with a variation of the other formula you published.
Here's the final formula I used that seems to be working:
RollingCount =
Hi,
Try this measure
=calculate(distinctcount(Data[CustomerID]),datesbetween(calendar[date],edate(min(calendar[date]),-11),min(calendar[date])))
Please ensure the following:
Hope this helps.
Thanks guys! Both formulas work, but I'm noticing some weird behavior when I drill down past the year:
The last four months are way off. My Date Dim and Fact Tables end on the current date so I'm not sure how to address the issue with the last four columns. Any ideas?
Hi,
Share the link from where i can download your PBI file.
@dedelman_clng I have it working with a variation of the other formula you published.
Here's the final formula I used that seems to be working:
RollingCount =
Hi @StephenK -
The general pattern for Rolling 12 months would be
CALCULATE( [Measure], DATESBETWEEN('Date'[Date], MIN('Date'[Date]) - 365, MIN('Date'[Date])))
This should work at every date hierarchy level (1st of the month for month, 1st of the year for year) if you're using a dedicated date table.
Hope this helps
David
User | Count |
---|---|
84 | |
73 | |
67 | |
42 | |
35 |
User | Count |
---|---|
109 | |
56 | |
52 | |
45 | |
43 |