Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hey guys, If I use the following calculation:
Event rate = COUNT[Events]/DISTINCTCOUNT[Date]
I find that the numerator is lower by the number of days an event didn't happen. For example, if I plot Event rate vs. time (by month) my rate will be artificially high if there are dates no event occurred because it will not count these dates.
Any suggestions? I've also tried using DATEDIFF(MIN(Date), MAX(Date),DAYS) which gets me closer but will also be artificially high if an event doesn't happen on the first or last date.
Thanks!
Solved! Go to Solution.
I figured out a solution that is working. It required the use of a date table and creating a relationship in the model. Then I could use as my denomentator Countrows('DateTable'[Day])
I figured out a solution that is working. It required the use of a date table and creating a relationship in the model. Then I could use as my denomentator Countrows('DateTable'[Day])
Does that mean your calendar table only spans the same date range as your data table?
When I have a calendar table that spans a date range greater than the source data, and I use the measure:
Event rate = COUNT[Events]/Countrows('DateTable'[Day])
The rate value is affected by the size of the Calendar table.
I.e. If I set my calendar table from data start to 2099, the rate is super low.
If I set my calendar table (m query source) from data start date to 20211, the rate is higher. (Okay that may be a bit captain obvious, but I wanted to be clear.)
This is what I did to get mine to work, verified with an excel manual calculation:
Thanks for the suggestion! I tried that but it still does not account for days that no event occured. I attached a test data set. When I select a particular week, only 5 distinct day counts even though there was 7 days. I want to get the 3.71events/day vs. the 5.20events/day (basically dividing the number of events by 7 instead of 5)
Hi @pagrosse ,
Based on your sample data and description, what cnfused me is that since there are 7 days in a week, just divide by 7 directly as you write in the formula. Why do we need to get 7 by calculation as the denominator?
Maybe you can consider sharing more details about this issue for further discussion.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@pagrosse , Try a measure like
Event rate = divide(COUNT(Table[Events]),calculate(DISTINCTCOUNT(Table[Date]), filter(Table, not(isblank(Table[Events])))))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |