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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Newbie12345
Regular Visitor

Need Urgent HELP! on DAX

Dear All,

I want to show the sub total in a separate column in the matrix visual as shown in the screenshot. 
Population is a measure, not a direct column from the database. 
NOTE: Country is from different table and State is from different table. 
           Same State Name will be there in different countries

Can someone please help me around with this?


Newbie12345_1-1712312708143.png

 

 


Thank you.


1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Newbie12345 

 

@gmsamborn Thank you very much for your prompt reply, and here allow me to make some comments of my own.

 

Power BI does not inherently support displaying subtotals in separate columns within the same matrix. However, you can create a separate visual to show totals.

 

For your question, here is the method I provided:

 

Check to see if there is a relationship between the "Country" and "State" tables in the model. If not, make sure there is a public key that links these tables directly or indirectly.

 

vnuocmsft_0-1712556267187.png

 

Since you mentioned that "Population" is a metric and not a direct column, you will need to create a metric using DAX to correctly calculate subtotals for different states and countries.

 

Sub Total = 
SUMX(
    FILTER(
        'Country / State', 
        'Country / State'[Country] = MAX('Country / State'[Country])
    ), 
    'Country / State'[Measure Population]
)

 

You can create a card for displaying Sub Total.

 

vnuocmsft_1-1712556472448.png

 

Also used in conjunction with the slicer for showing population totals under different countries.

 

vnuocmsft_2-1712556518637.png

Regards,

Nono Chen

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

4 REPLIES 4
Anonymous
Not applicable

Hi @Newbie12345 

 

@gmsamborn Thank you very much for your prompt reply, and here allow me to make some comments of my own.

 

Power BI does not inherently support displaying subtotals in separate columns within the same matrix. However, you can create a separate visual to show totals.

 

For your question, here is the method I provided:

 

Check to see if there is a relationship between the "Country" and "State" tables in the model. If not, make sure there is a public key that links these tables directly or indirectly.

 

vnuocmsft_0-1712556267187.png

 

Since you mentioned that "Population" is a metric and not a direct column, you will need to create a metric using DAX to correctly calculate subtotals for different states and countries.

 

Sub Total = 
SUMX(
    FILTER(
        'Country / State', 
        'Country / State'[Country] = MAX('Country / State'[Country])
    ), 
    'Country / State'[Measure Population]
)

 

You can create a card for displaying Sub Total.

 

vnuocmsft_1-1712556472448.png

 

Also used in conjunction with the slicer for showing population totals under different countries.

 

vnuocmsft_2-1712556518637.png

Regards,

Nono Chen

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

 

 

lukiz84
Memorable Member
Memorable Member

SubTotal = CALCULATE([Population], ALL(YourStateTable))

Dear @lukiz84 ,

Thanks for your response! 
The problem here is, I have same state name in other countries too, so we can not use ALL, 
I tries ALLEXCEP as well but since it is a matrix, it is giving row level value along with subtotal. 
Want I am trying to get here is, only Subtotal like a merged single value (as shown in the screenshot above)

Hi @Newbie12345 

 

I'm not sure you can make a matrix column appear to be a Excel merged column.

 

Regarding your measure, would this help?

Subtotal = 
    IF(
        NOT HASONEVALUE( 'Table'[State] ),
        CALCULATE(
            SUM( 'Table'[Population] ),
            REMOVEFILTERS( 'Table'[State] )
        )
    )

 

I hope this helps.



Proud to be a Super User!

daxformatter.com makes life EASIER!

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.