Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Need help

I need help with writing a dax to return a true or false if a value is found in the column after it was filtered by job number 

eg: the value to be looked for is red 

It's supposed to return true for job number 1 since red is in the second row. For job 2 and 3 it returns false because red is nowhere in the colour column for these job numebrs

job numbercolour true/false
1bluetrue
1redtrue
1orangetrue
2yellowfalse
2blackfalse
3whitefalse
3pinkfalse
3brownfalse
1 ACCEPTED SOLUTION

@Anonymous ,

There are a few different ways this could be done.  But I would simply change the IF to a SWITCH function:

True/False2 = 
VAR _Currentjobnumber = [job number]
VAR _Colour = SUMMARIZE( FILTER( Colour, Colour[job number] = _Currentjobnumber), Colour[colour])
VAR _Result = SWITCH(
                  TRUE(),
                  "red" in _Colour, "True",
                  "gray" in _Colour, "True",
                  "False" )

RETURN
    _Result

The SWITCH is similar to a nested IF, allows for multiple conditions but is much cleaner and easier to read.

Now you can add as many colours as you need.

Regards,

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks @rs 

What if I want to add more than one value to look for ? 

example: red and gray 

@Anonymous ,

There are a few different ways this could be done.  But I would simply change the IF to a SWITCH function:

True/False2 = 
VAR _Currentjobnumber = [job number]
VAR _Colour = SUMMARIZE( FILTER( Colour, Colour[job number] = _Currentjobnumber), Colour[colour])
VAR _Result = SWITCH(
                  TRUE(),
                  "red" in _Colour, "True",
                  "gray" in _Colour, "True",
                  "False" )

RETURN
    _Result

The SWITCH is similar to a nested IF, allows for multiple conditions but is much cleaner and easier to read.

Now you can add as many colours as you need.

Regards,

rsbin
Super User
Super User

@Anonymous .

Please try the following as a Calculated Column:

True/False = 
VAR _Currentjobnumber = [job number]
VAR _Colour = SUMMARIZE( FILTER( Colour, Colour[job number] = _Currentjobnumber), Colour[colour])

RETURN
   IF( "red" IN _Colour, "True", "False" )
job number colour True/False
1 blue True
1 red True
1 orange True
2 yellow False
2 black False
3 white False
3 pink False
3 brown False

Regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.