Forum Discussion

telesforo1969's avatar
1 year ago
Solved

Measure to add two values from two different columns that meet a condition.

I have a table containing the rows shown in image 1. I would like help creating a measure to sum values from two columns that meet the condition of being equal in type. Figure 2 shows the result.   ...
  • Irwan's avatar
    1 year ago

    hello telesforo1969 

     

    in addition of ryan_mayu 's solution, you can use DAX.

    Sum =
    var _Tipo = SELECTEDVALUE('Table'[Tipo1])
    Return
    SUM('Table'[Costo1])
    +
    CALCULATE(
        SUM('Table'[Costo2]),
        FILTER(
            ALL('Table'),
            'Table'[Tipo2]=_Tipo
        )
    )
    you can choose which way that suit your preferences.
     
    Hope this will help.
    Thank you.