Skip to main content
cancel
Showing results for
Search instead for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

New Member

## Challenge with SUM of AVERAGES

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] ))RETURNIF (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?:)

3 REPLIES 3
Super User
Super User

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

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

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

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

## Helpful resources

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors