Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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 f...
  • rsbin's avatar
    rsbin
    3 years ago

    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,