Forum Discussion

Mimi_Ibrahim's avatar
Mimi_Ibrahim
Icon for Helper I rankHelper I
2 years ago
Solved

IF contains in a group, return value

Hi Team, 

 

Can someone help me with a measure that will show as Result in below table please?

The condition is, if Group 2 contains X, then the Result = Red be applied to the whole row based on Group 1, else Result = Green.

Any help is much appreciated! Thank you!.

 

Group 1Group 2Result
Malaysia1Green
Malaysia1Green
Malaysia1Green
Singapore1Red
SingaporeXRed
Singapore1Red
SingaporeXRed
Thailand1Red
ThailandXRed
Thailand1Red
  • Hello Mimi_Ibrahim,

     

    Can you please try this:

    Result Measure = 
    VAR CurrentGroup1 = MAX('Table'[Group 1])
    VAR IsXInGroup = CALCULATE(
        CONTAINS('Table', 'Table'[Group 2], "X"),
        ALL('Table'),
        'Table'[Group 1] = CurrentGroup1
    )
    RETURN
    IF(IsXInGroup, "Red", "Green")
    

2 Replies

  • Hello Mimi_Ibrahim,

     

    Can you please try this:

    Result Measure = 
    VAR CurrentGroup1 = MAX('Table'[Group 1])
    VAR IsXInGroup = CALCULATE(
        CONTAINS('Table', 'Table'[Group 2], "X"),
        ALL('Table'),
        'Table'[Group 1] = CurrentGroup1
    )
    RETURN
    IF(IsXInGroup, "Red", "Green")