Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I need to create a measure Average Discharges per Day, its formula is Total Discharges at any point in time date divided by number of days in that point in time.
But I am not getting the correct results due to incorrect denominator.
For eg. If I want to see the discharges in Calendar Year 2021 and upto today i.e. 9 Feb the calculation would be Total Discharges till 09-Feb-21 divided by 40(31 [days in Jan] + 9[days in Feb]). But whatever calculation I use, ends up counting 28 days for Feb in the denominator, which becomes 59 days instead of 40, thus lowering the average.
I have tried below three different calculations to get the right denominator, but all of these are counting 28 days in Feb instead of counting days in Feb till today i.e. 9th Feb :
How to get the count of dates only till current date in the denomintor.
Here the time period selected can be in terms of Financial Year instead of Calenday Year, still the denominator should be counting the days from 01-July-2020 till 09-Feb-2021 if current financial year is selected.
Solved! Go to Solution.
Measure that is working with all filters :
Thanks for the help and for responding with the solution. It was working fine if the only filters applied on report were from Date table but any filter on Hospital name or ward name was breaking the measure. I was able to come up with the measure that worked fine with all the different filters on report.
It is :
NumberOfDays :=
VAR MaxDate = MAX('Date'[Date])
VAR CurrentDate = TODAY()
RETURN
IF ( MaxDate >= CurrentDate,
COUNTROWS(CALCULATETABLE('Date', FILTER('Date','Date'[Date] < CurrentDate))),
COUNTROWS('Date')
)
Measure that is working with all filters :
Thanks for the help and for responding with the solution. It was working fine if the only filters applied on report were from Date table but any filter on Hospital name or ward name was breaking the measure. I was able to come up with the measure that worked fine with all the different filters on report.
It is :
NumberOfDays :=
VAR MaxDate = MAX('Date'[Date])
VAR CurrentDate = TODAY()
RETURN
IF ( MaxDate >= CurrentDate,
COUNTROWS(CALCULATETABLE('Date', FILTER('Date','Date'[Date] < CurrentDate))),
COUNTROWS('Date')
)
@RachnaV , Try a measure like
Avg YTD Sales =
divide(CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31")),CALCULATE(countx(filter(values('Date'[Date]), not(isblank(calculate(SUM(Sales[Sales Amount]))))),'Date'[Date])))
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 |
---|---|
54 | |
27 | |
23 | |
14 | |
11 |
User | Count |
---|---|
77 | |
63 | |
44 | |
17 | |
12 |