Forum Discussion

Singh_Yoshi's avatar
Singh_Yoshi
Helper I
1 year ago
Solved

DAX Code not working

I have following table in BI.  Item Cost 18" Alloy -23000 20" Alloy 31000 Air Bag 5000 Deatc 250   I want to subtract 18" Alloy cost(-23000) from 20" Alloy(31000) and remove...
  • danextian's avatar
    1 year ago

    Hi Singh_Yoshi 

     

    Please try this:

    Measure1 = 
    VAR _alloy =
        CALCULATE (
            SUM ( SampleData[Cost] ),
            FILTER (
                ALL ( SampleData[Item], SampleData[Cost] ),
                SampleData[Item] IN { "18"" Alloy", "20"" Alloy" }
            )
        )
    RETURN
        SWITCH (
            TRUE (),
            SELECTEDVALUE ( SampleData[Item] ) = "18"" Alloy", BLANK (),
            SELECTEDVALUE ( SampleData[Item] ) = "20"" Alloy", _alloy,
            SUM ( SampleData[Cost] )
        )