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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DAX for Summarizing at an aggregate level

I have two tables. One with the total sale amount for the month by car and another with the details showing car, model, and sales person. I have merged the to tables together and need to find a way to write dax that gives me the sum of the amount sold without over counting. **NOTE in my example I do not have the ability to split these tables out into two tables and relate them so I need a DAX that can work off the belnded fact table (Table 3).

 

I need a DAX measure that sums the amount for cars sold. In table 1 below the total amount that was sold was $2400. (1000 + 200 + 400 + 800). You can see on the green merged table 2 below those amount values are duplicated and I need to be able to sum the column, but sum the unique values by car.

 

Sales Amount for the month by Car (Table 1)

tbuckinghamPL_0-1670681744120.png

 

Sales Detail (Table 2)

tbuckinghamPL_1-1670681765466.png

 

Table 3: Blended Fact Table (Main Fact Table I need DAX built off of)

tbuckinghamPL_2-1670681786428.png

 

Here is the formula I have showing the "INCORRECT" value....

Sales Amount:=SUM(Table3[Amount])

 

tbuckinghamPL_3-1670682125007.png

7,200 is not the right amount, it should be 2,400 for the month.

 

I need a dax formula that shows me this....

tbuckinghamPL_4-1670682166738.png

 

How do you write dax off Table 3 that gives you the table above showing 2,400, if the amount values from the first table are duplicated when merged with the second table?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

 

Try: 

Measure 2 = 
    VAR __Table = GROUPBY('Table5',[Car],"__Avg",AVERAGEX(CURRENTGROUP(),[Amount]))
    VAR __Result = SUMX(__Table,[__Avg])
RETURN
    __Result


This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Yep that worked! Curious if there is another way to write the formula without the Average? Could you leverage SUMMARIZE somehow?

@Anonymous Well, there are a couple ways of going about it but that way was the simplest for your scenario. SUMMARIZE can get you in trouble sometimes.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@Anonymous First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

 

Try: 

Measure 2 = 
    VAR __Table = GROUPBY('Table5',[Car],"__Avg",AVERAGEX(CURRENTGROUP(),[Amount]))
    VAR __Result = SUMX(__Table,[__Avg])
RETURN
    __Result


This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.