Forum Discussion
Average measure per Weekday selection: Handling no data
Hi all,
I'd like to have an average visits measure per weekday selection for this case: When I select Monday and Tuesday and see there are no data fro Tuesday, the average measure should calculate Tuesday as well:
For this example in the screenshot, the avg result should be 44 / 2 (selected days) = 22
and not 44. How can this be achieved?
My current measure =
Thank you!
- Anonymous3 years ago
Hi Dn_wemn ,
I think you issue should be caused that data table do not have "Tuesday" value. Here I suggest you to create a continuous DimDate table to help you calculate.
DimDate:
Date = ADDCOLUMNS ( CALENDAR ( MIN ( 'Table'[Start Time ] ), MAX ( 'Table'[Start Time ] ) ), "DayDesc", FORMAT ( [Date], "DDDD" ), "Day", WEEKDAY ( [Date], "2" ) )Relationship:
Use the [DayDesc] column in that 'Date' column.
My current measure = AVERAGEX ( KEEPFILTERS ( VALUES ( 'Date'[DayDesc] ) ), CALCULATE ( [Visits] + 0 ) )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- grantsamborn
Solution Sage
Hi Dn_wemn
Could you show:
(a) sample source dataset
(b) your expected end result
(c) a description of how you would expect to get from (a) to (b).
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
Thanks,
Grant
- AnonymousNot applicable
Hi Dn_wemn ,
I think you issue should be caused that data table do not have "Tuesday" value. Here I suggest you to create a continuous DimDate table to help you calculate.
DimDate:
Date = ADDCOLUMNS ( CALENDAR ( MIN ( 'Table'[Start Time ] ), MAX ( 'Table'[Start Time ] ) ), "DayDesc", FORMAT ( [Date], "DDDD" ), "Day", WEEKDAY ( [Date], "2" ) )Relationship:
Use the [DayDesc] column in that 'Date' column.
My current measure = AVERAGEX ( KEEPFILTERS ( VALUES ( 'Date'[DayDesc] ) ), CALCULATE ( [Visits] + 0 ) )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Dn_wemn
Helper II
Thank you for your effort. This has helped me to adapt the data 🙂
I already did the same with date table and also tried to filter out data of Tuesdays in a measure, but it works when this is done in the table of Power Query. After that pre-work, it also works with the measure