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
Grygger
Frequent Visitor

Different DAX calculations for different row hierarchies in a matrix table? Independent subtotals?

I have a matrix visual in which I am trying to show sales targets for each sales territory. These territories then roll up into a region. The challenge is that sales regions have higher sales targets than all their respective territories and therefore I cannot aggregate the territory sales targets to get the region's overall sales target (regional sales targets being higher).

 

In a PowerBI matrix, I'm trying to create a DAX formula that would populate the respective region's target and each respective territories target based on the row being shown. Keep in mind, these are independent of eachother.

 

I have this formula here which is not working. What I'm intending to do is if the row contains a region, then return a calculation that aggregates the sales targets for that specific region. Otherwise, it'll return sales territory targets.

The 'role' column defines whether the target is specific to a region or to a territory, having values as either Region or Territory.

 

Target Switch Function = 
VAR CurrentRegion = SELECTEDVALUE(Revenue[Territory])

RETURN 
SWITCH(TRUE(), 
    CurrentRegion = "AM-CA-CA-PR", CALCULATE(SUM(Revenue[Target]), Revenue[Role]="Region"),
    CurrentRegion = "AM-CA-CA-PS", CALCULATE(SUM(Revenue[Target]), Revenue[Role]="Region"),
    CALCULATE(SUM(Revenue[Target]), Revenue[Role]="Territory"))

 

 

My existing matrix table looks like

Grygger_3-1634069832959.png

 

And my desired output is below, with the regional subtotals being higher than the territorial. Note that the region totals are higher than the total sum of the total territories and this is what I'm trying to get the DAX formula to do.

 

Grygger_2-1634069815840.png

 

 

 

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

Hi, @Grygger 

 

Using the IF and ISINSCOPE functions, you can customize the calculation of each level of the matrix.
I'll use an example to illustrate this, see the following screenshot.

vangzhengmsft_0-1634282613641.png

Switch = 
var _territoty=1
var _region=2
var _Total=3
return 
IF (
    ISINSCOPE ( 'Table'[Region] ),
    IF ( ISINSCOPE ( 'Table'[Territory] ), _territoty, _region ),
    _Total
)

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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
v-angzheng-msft
Community Support
Community Support

Hi, @Grygger 

 

Using the IF and ISINSCOPE functions, you can customize the calculation of each level of the matrix.
I'll use an example to illustrate this, see the following screenshot.

vangzhengmsft_0-1634282613641.png

Switch = 
var _territoty=1
var _region=2
var _Total=3
return 
IF (
    ISINSCOPE ( 'Table'[Region] ),
    IF ( ISINSCOPE ( 'Table'[Territory] ), _territoty, _region ),
    _Total
)

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

And for it?

1

2

3 = 1 - 2

4

5 = 3 - 4

6

7 = 5 + 6


This table is a "table/matrix".

 

The calcuus is different for each row or row 3, 5 and 7. Can you help me?

YukiK
Impactful Individual
Impactful Individual

You may be able to leverage a function like ISINSCOPE() to check if a specific column is in scope. I'd try something like:

IF ( ISINSCOPE( REGION ), Measure1, Measure2 )

 

Hope that helps!

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.

Top Solution Authors