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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nick555
Helper I
Helper I

Switch Statement Not Evaluating Properly

Greetings!

 

I am trying to use a Switch statement to populated a column with values. IT only evaluates the first part and not the second. This leaves me with a column of 1's and blanks instead of 1's, 2's and blanks. Any ideas what I am doing worng?

Thanks

TEST =
    SWITCH(
        TRUE(),
        'Sheet1'[COVRG_CD] <> "X1" && 'Sheet1'[COVRG_CD] <> "Y1" && 'Sheet1'[COVRG_CD] <> "Z1" && 'Sheet1'[PLAN_TYPE] = "10", "1",
        'Sheet1'[COVRG_CD] = "X1" && 'Sheet1'[COVRG_CD] = "Y1" && 'Sheet1'[COVRG_CD] = "Z1" && 'Sheet1'[PLAN_TYPE] = "10" && 'Sheet1'[Dependent ID] <> BLANK(), "2",
        BLANK()
    )
1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @Nick555 

You can try this code:

TEST =
    SWITCH(
        TRUE(),
        'Sheet1'[COVRG_CD] in {"X1","Y1","Z1"}=FALSE() && 'Sheet1'[PLAN_TYPE] = "10", "1",
        'Sheet1'[COVRG_CD]  in {"X1","Y1","Z1"} && 'Sheet1'[PLAN_TYPE] = "10" && 'Sheet1'[Dependent ID] <> BLANK(), "2",
        BLANK()
    )

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Nick555
Helper I
Helper I

Many Thanks! This worked perfectly! 

v-xinruzhu-msft
Community Support
Community Support

Hi @Nick555 

You can try this code:

TEST =
    SWITCH(
        TRUE(),
        'Sheet1'[COVRG_CD] in {"X1","Y1","Z1"}=FALSE() && 'Sheet1'[PLAN_TYPE] = "10", "1",
        'Sheet1'[COVRG_CD]  in {"X1","Y1","Z1"} && 'Sheet1'[PLAN_TYPE] = "10" && 'Sheet1'[Dependent ID] <> BLANK(), "2",
        BLANK()
    )

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.