Forum Discussion

Giada90's avatar
Giada90
Helper IV
4 years ago
Solved

problem with a calculation

Hi, 

I have a table with two fields like this:

typevalue
A10
B3

 

I need to make a measure that subtracts value A from value B

Which dax formula can I use?

Thanks

  • ddpl's avatar
    ddpl
    4 years ago

    Giada90 try this

     

    Measure 2 = var _A = CALCULATE(SUM('Yourtable'[value]),'Yourtable'[type] = "A")

    var _B = CALCULATE(SUM('Yourtable'[value]),'Yourtable'[type] = "B")

    return

    (_A - _B)

11 Replies

  • Hi Giada90 ,

     

    You can create a DAX expression to get this done.

    But before that you will need to add an Index column to your data.

    I am not sure on how big is your data?

    You haven't mentioned if you need to do this subtraction at you type column level or something else? This information is needed to understand whether you have multiple rows for same type.

    Please provide atleast 5-10 rows in your sample data, to cover all the scenarios.

    https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

     

    • Giada90's avatar
      Giada90
      Helper IV

      Pragati11 , Hi, the real model is about 1700 rows and I need to do this substraction at my type column level, thanks

      • Pragati11's avatar
        Pragati11
        Super User

        Hi Giada90 ,

         

        So can you please provide more number of rows in your sample data please rather than just 2 rows?