Forum Discussion

Kaymen's avatar
Kaymen
New Member
2 years ago
Solved

Customized Total Row (sum of top 4) in table Visualization

Hello,

 

I am looking to get a customized value in the total row for table visualization in Power BI.
I would like the total to be the sum of the top 4 rows only.
Below is a screenshot of the data table and result that I am trying to achieve.

 

 


Thanks in advance for your help !

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Kaymen ,

    You can try the DAX below:

    Top4_Sum = 
    SUMX(TOPN(4, ALL('Table'[Points]), 'Table'[Points], DESC), 'Table'[Points])

    The DAX first sorts the values of the points column from highest to lowest, and then calculates the sum of the first 4 columns.
    The results are shown in the figure below:

     

    Best Regards,

    Dino Tao

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

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Kaymen ,

    You can try the DAX below:

    Top4_Sum = 
    SUMX(TOPN(4, ALL('Table'[Points]), 'Table'[Points], DESC), 'Table'[Points])

    The DAX first sorts the values of the points column from highest to lowest, and then calculates the sum of the first 4 columns.
    The results are shown in the figure below:

     

    Best Regards,

    Dino Tao

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