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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

question about switch

I have a requirement where I have to match one expression with multiple values (from syntax below)

 

SWITCH(<expression>, <value>, <result>[, <value>, <result>]…[, <else>])

 

I am writing a psuedocode of exactly what I am looking for, Question is, how do i match one <expression> with more than one values for<value> in above syntax

 

IF column IN ('a','b','c','d','e','f') -- 1
THEN


IF (column2 like '%tst%' OR column IN ('a','b') ) -- 2 THEN

IF column IN ('d','e') THEN
[use this column];
ELSIF column IN ('b','d','e','f') THEN
[use this column];
END IF;

ELSE -- 2

0

END IF; -- 2


END IF; -- 1

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create measures

Measure 1 = IF(ISERROR(SEARCH("tst",MAX(Sheet7[column2]),1)),0,SEARCH("tst",MAX(Sheet7[column2]),1))

Measure =
IF (
    MAX ( Sheet7[column] ) IN { "a", "b", "c", "d", "e", "f" },
    IF (
        [Measure 1] <> 0
            || MAX ( Sheet7[column] ) IN { "a", "b" },
        IF (
            MAX ( Sheet7[column] ) IN { "d", "e" },
            [use this column],
            IF ( MAX ( Sheet7[column] ) IN { "b", "d", "e", "f" }, [use this column] )
        ),
        0
    )
)

4.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

How can I write a calculated column, instead of a measure 

Hi @Anonymous 

Create columns

Column 2 = IF(ISERROR(SEARCH("tst",Sheet7[column2],1)),0,SEARCH("tst",Sheet7[column2],1))

Column 3 =
IF (
    Sheet7[column] IN { "a", "b", "c", "d", "e", "f" },
    IF (
        [Column 2] <> 0
            || Sheet7[column] IN { "a", "b" },
        IF (
            Sheet7[column] IN { "d", "e" },
            [use this column],
            IF ( Sheet7[column] IN { "b", "d", "e", "f" }, [use this column] )
        ),
        0
    )
)

1.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks, I am using visual studio 2012 version, is IN not supported there, I get error  'IN' is incorrect

Hi @Anonymous 

Do you use Power BI Desktop of Power BI Report server?

You can see the supported system where Power BI Desktop can be installed.

3.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you for your response

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.