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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
T-Ilias
Regular Visitor

Multi level measure with DAX

Hello everyone,

 

Could you please help me on this calculation ?

I have a table called cost, looks something like this :

 

MarketProduction centerYearL1 Cost StructureL2 Cost StructureL3 Cost StructureCost in Mio USDSales Volume in Mio
Spain1B2022Consumable material Cat1Consumable material L2 Cat1Consumable material L3 Cat1 X2.319
Spain1B2022Packagin material Cat1Packagin material L2 Cat1Packagin material L3 Cat1 Y1.719
Spain1B2022Consumable material Cat1Consumable material L2 Cat1Consumable material L3 Cat1 Z319
Spain1B2022Packagin material Cat1Packagin material L2 Cat1Packagin material L3 Cat1 T419

 

the measure i'm trying to create is cost per 1k unit and then plug it on matrix to act as below :

 

on L3 cost structure the measure should display : (Sum(cost in Mio USD)/Sum(sales volume) )* 1000
on L2 cost structure it would sum the lines of L3 cost structure 
on L1 cost structure it would sum the lines of L2 cost structure 

 

methods i have tried : 

Method 1:

 

price 1k=
(
    (SUM(Cost[Cost(M USD)]))
/
CALCULATE(
    SUM(Cost[Sales Volume(M)]))
)*1000
RETURN

SUMX(Cost,SVC_Rate)


Method 2 :
L3Level = CALCULATE( SUM( 'Cost'[Cost(M USD)] ) / SUM( 'Cost'[Sales Volume(M)] ) * 1000, ALL( 'Cost' ), 'Cost'[L3 Cost Structure] = SELECTEDVALUE('Cost'[L3 Cost Structure]) )
L2Level = CALCULATE( SUMX( FILTER( ALL( 'Cost' ), 'Cost'[L2 Cost Structure] = SELECTEDVALUE('Cost'[L2 Cost Structure]) ), [L3Level] ), ALL( 'Cost' ) )
L1Level = CALCULATE( SUMX( FILTER( ALL( 'Cost' ), 'Cost'[L1 Cost Structure] = SELECTEDVALUE('Cost'[L1 Cost Structure]) ), [L2Level] ), ALL( 'Cost' ) )
Cost k/unit=
    SWITCH(TRUE(),
        SELECTEDVALUE('Cost'[L3 Cost Structure]), [L3Level],
        SELECTEDVALUE('Cost'[L2 Cost Structure]), [L2Level],
        SELECTEDVALUE('Cost'[L1 Cost Structure]) , [L1Level]
    )
Appreciate your tips and inputs.
Cheers,

 

1 ACCEPTED SOLUTION

Thanks.
I end up doing this : 

   SUMX(
        SUMMARIZE(
            'Cost',
            'Cost'[L1 Cost Structure],
            'Cost'[L2 Cost Structure],
            'Cost'[L3 Cost Structure],
            "CostPerVolume", SUM('Cost'[Cost(M USD)]) / SUM('Cost'[Sales Volume(M)]) * 1000
        ),
        [CostPerVolume]
    )
 
And it worked. will try the inscope too just to have options in future.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@T-Ilias , You can use isinscope to handle this, but it work in Bar, Matrix not Table visual

 

// in method two

SWITCH(TRUE(),
Isinscope('Cost'[L3 Cost Structure]), [L3Level],
Isinscope('Cost'[L2 Cost Structure]), [L2Level],
Isinscope('Cost'[L1 Cost Structure]) , [L1Level]
)

 

IsInScope - Switch Rank at different levels: https://youtu.be/kh0gezKICEM

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks.
I end up doing this : 

   SUMX(
        SUMMARIZE(
            'Cost',
            'Cost'[L1 Cost Structure],
            'Cost'[L2 Cost Structure],
            'Cost'[L3 Cost Structure],
            "CostPerVolume", SUM('Cost'[Cost(M USD)]) / SUM('Cost'[Sales Volume(M)]) * 1000
        ),
        [CostPerVolume]
    )
 
And it worked. will try the inscope too just to have options in future.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors