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

View all the Fabric Data Days sessions on demand. View schedule

Reply
AZ2021
New Member

DAX formula to show calculation within a matrix

Hi guys,

 

I am trying to use this code to show the figure for Gross Profit, EBITDA and Net Profit.

 

The logic will be using this DAX Code to run through the title coloumn, whenever it sees column matching the description "Gross Profit", "EBITDA", "Net Profit", it will use my measures I created to calculate the relevant figure. 

 

However it is not showing figures somehow. There must be some error within my DAX formula. Much appreciate if someone can help.

AZ2021_0-1627623242708.png

 

1 ACCEPTED SOLUTION

Hi @AZ2021 ,

 

Based on solution provided, you need to update your code as below

SelectedYearActual =
VAR CurrentItem =
    MAX ( Mapping[COA - Level 1] )
RETURN
    SWITCH (
        TRUE (),
        SEARCH ( "Gross Profit", CurrentItem,, 0 ) > 0, [Gross Profit],
        SEARCH ( "EBITDA", CurrentItem,, 0 ) > 0, [EBITDA],
        SEARCH ( "Net Profit", CurrentItem,, 0 ) > 0, [Net Profit],
        CALCULATE ( [Correct sign figure] )
    )

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@AZ2021 , change selectedvalue with MAX. and check. Also, check are there is any space in the name. or use search in place of =

 

example 

Switch(true() ,

search("Gross Profilt", max(Mapping[COA level 1]),,0) >0, [Gross profit],

// Add others

)

 

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

Hi  amitchandak,

 

Thank you for your response. I replaced my code with your suggestion but an error pop.

AZ2021_0-1627627059726.png

 

Hi @AZ2021 ,

 

Based on solution provided, you need to update your code as below

SelectedYearActual =
VAR CurrentItem =
    MAX ( Mapping[COA - Level 1] )
RETURN
    SWITCH (
        TRUE (),
        SEARCH ( "Gross Profit", CurrentItem,, 0 ) > 0, [Gross Profit],
        SEARCH ( "EBITDA", CurrentItem,, 0 ) > 0, [EBITDA],
        SEARCH ( "Net Profit", CurrentItem,, 0 ) > 0, [Net Profit],
        CALCULATE ( [Correct sign figure] )
    )

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

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