Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello PBI Community!
So, I have a challenge with DAX. My end-users want to see AVERAGE of products sold for each weekday but the Grand Total should be a SUM of these AVERAGES. I wrote some DAX:
So my code looks like that:
sumOfAverages =
VAR avgFull =
CALCULATE (
SUM ( [sold_qt] )
/ DISTINCTCOUNT ( [delivery_date] )
)
RETURN
IF (
HASONEVALUE ( [weekday_name] ),
avgFull,
SUMX ( VALUES ( date_weekday_dim[weekday_name] ), avgFull )
)
Actually it's working only if I have selected all the weekdays. See the screen below. If I select something on slicers and there won't be any data from particular weekday it looks like that.
So the Grand Total is not correct. I think that there's a problem with SUMX (VALUES ... )) section in DAX but really don't know how to figure it out.
Could you help me with this, please?:)
Hi @kashanka ,
Created a table, then on visuals a slicer, and a matrix, then a measure.
Sum of Daily Averages = SUMX(DailyAverages,Divide(DailyAverages[Sold],DailyAverages[DistinctCount]))
This should work if I understand your issue.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
Hi @kashanka ,
If one of the days has no values...
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
21 | |
11 | |
10 | |
9 | |
8 |