Forum Discussion
Add Total using DAX
- 3 years ago
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:
(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:
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
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.