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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Calculated Measure

Account NameDateAmount
Rev12-Jun-18430
Exp13-Aug-17250
Margin2-Mar-170
Rev12 July 18400
Exp13-Aug-17300

 

I have a table where I need to create a calculated measure based on the below logic

 

If the Account Name <> 'Margin' then Sum of amount

if the Account Name = "Margin' then Sum of amount =

Sum of Amount when account name is 'Rev' -  Sum of Amount when account name is 'Exp'

1 REPLY 1
Stachu
Community Champion
Community Champion

try this

Measure =
IF (
    SELECTEDVALUE ( 'Table'[Account Name] ) = "Margin",
    CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Account Name] = "Rev" )
        - CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Account Name] = "Exp" ),
    SUM ( 'Table'[Amount] )
)

if you have more cases like this it may be better to embed the logic in a new table, e.g. like this:

MeasurePositiveNegative
MarginRevExp
Margin2RevExp2

something similar to what's described here:
https://community.powerbi.com/t5/Desktop/Create-calculated-row/td-p/440613



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.