Forum Discussion

rgtanna's avatar
rgtanna
New Member
7 years ago
Solved

Create conditional measure

Greetings,    I'm trying to create a conditional measure that sums up all "stage 1" values only if "stage 3" has a value for the row item.   The data below is of sample source data, but when impo...
  • d_gosbell's avatar
    7 years ago

    It would be easier if we could see the data as it exists in the tabular table. But if I understand your issue correctly the following psuedo code should work

     

    = SUMX( table1 ,
       IF( calculate(SUM(table1[Value]) , table1[Stage] = "Stage 3) > 0 ,
          IF( table1[Stage] = "Stage 1", table1[Value] )
       )
    )

  • v-jiascu-msft's avatar
    7 years ago

    Hi rgtanna ,

     

    Please also try this one.

     

    Measure 2 =
    VAR hasStage3Items =
        CALCULATETABLE ( VALUES ( Table1[Item] ), Table1[Stage] = "Stage 3" )
    RETURN
        CALCULATE (
            SUM ( Table1[Value] ),
            FILTER ( Table1, Table1[Item] IN hasStage3Items && Table1[Stage] = "Stage 1" )
        )
    

     

     

     

    Best Regards,