Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Add Total using DAX

Hi All,   I have three tables as shown in the below screenshot:     The Filter Condition column will be placed as a filter in the report. Based on the filter selection, the result should b...
  • v-yueyunzh-msft's avatar
    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