Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Multiple IF statements inside switch case

I have multiple statements that i need to validate for "category" column. I have written this DAX but i am getting an error "Switch doesnot support comparing values of type boolean with text ,consi...
  • AlB's avatar
    5 years ago

    Hi Anonymous 

    the first part has random non-DAX code like "starts with". For the secodn part, you'd need something like this. You'll probably have to adapt it a bit but you'll get the idea.

    Category =
    VAR cat_raw = 'Data'[Category_Raw]
    VAR new =
        SWITCH (
            TRUE (),
            AND (
                'Data'[Facility] = "BC",
                OR ( 'Data'[Type] = "YYYY", 'Data'[Type] = "YXYX" )
            ), "YContainer",
            AND ( 'Data'[Facility] = "CD", 'Data'[Type] = "CDCD" ), "DContainer",
            cat_raw
        )
    RETURN
        new

     Look at the syntax of SWITCH to understand well how it works

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers