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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

Add Total using DAX

Hi All,

 

I have three tables as shown in the below screenshot:

 

krishnanvs_0-1671988602060.png

 

The Filter Condition column will be placed as a filter in the report. Based on the filter selection, the result should be as follows:

 

krishnanvs_1-1671988775991.png

 

I can get values for the Capitals but I am not able to add the total for the rows highlighted in green. (Asia and Outside Asia). I have used DAX. May I know what DAX should i use to add the values.

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to add a total row in your table visual.Here are the steps you can refer to:
(1)My test data is the same as yours.

The table relationship is that:

vyueyunzhmsft_0-1672104347209.png

 

(2)Due to we have no right row headers , we need to click "New Table" to create a table as row headers in table visual:

Row headers = UNION( EXCEPT( ALL('Table 1'[Places]) ,  ALL('Table 2'[Places])) , DISTINCT('Table 2'[Capital])  )

(3)Then we can create a measure :

Measure = var _places = VALUES('Table 1'[Places])
var _capitals = VALUES('Table 3'[Capitals])
var _cur = MAX('Row headers'[Places])
var _total = CALCULATE( SUM('Table 3'[Value]))
var _sum = CALCULATE( SUM('Table 3'[Value]), TREATAS({_cur},'Table 3'[Capitals]))
return
IF(_cur in _places , _total , IF(_cur in _capitals , _sum,BLANK()))

 (4)Then we can put the field we need on the visual and we can meet your need:

vyueyunzhmsft_1-1672104373585.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Ideally you should not have the Filter condition column in Table1.  The column in that table instead should be Continent with only 2 entries under that column - Asia and Outside Asia.  Create a relationship (Many to One and Single) from Table3 to Table2.  In Table2, write this calculated column formula

Continent = lookupvalue('Table1'[continent],'Table1'[Places],'Table2'[Places])

Create a Continent slicer from Table2.  Write this measure

Measure = sum('Table3'[value])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to add a total row in your table visual.Here are the steps you can refer to:
(1)My test data is the same as yours.

The table relationship is that:

vyueyunzhmsft_0-1672104347209.png

 

(2)Due to we have no right row headers , we need to click "New Table" to create a table as row headers in table visual:

Row headers = UNION( EXCEPT( ALL('Table 1'[Places]) ,  ALL('Table 2'[Places])) , DISTINCT('Table 2'[Capital])  )

(3)Then we can create a measure :

Measure = var _places = VALUES('Table 1'[Places])
var _capitals = VALUES('Table 3'[Capitals])
var _cur = MAX('Row headers'[Places])
var _total = CALCULATE( SUM('Table 3'[Value]))
var _sum = CALCULATE( SUM('Table 3'[Value]), TREATAS({_cur},'Table 3'[Capitals]))
return
IF(_cur in _places , _total , IF(_cur in _capitals , _sum,BLANK()))

 (4)Then we can put the field we need on the visual and we can meet your need:

vyueyunzhmsft_1-1672104373585.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

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

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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