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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
cristianml
Post Prodigy
Post Prodigy

IN FUNCION IN CALCULATED COLUMN

Hi,

 

What is the most efficient way to do the following calculated column ?

 

If Table[Column] contains text1, text2, text3, etc then Result1 else

If Table[Column] contains text4, text5, text6, etc then Result2 

 

 

Can IN function be use to calculated columns ?

 

I tried the following but not sure if works or I should use other function ?

 

The criteria should be if column contains "SC", "CON","SI" then CON else 

if column contains "AO", "BPO","IO" then OUT else

"OTHERS" 

 

CON or OUT =
VAR V1 = CONTAINSSTRING('_List SG'[SG] IN { "SC", "CON","SI" },"CON")
VAR V2 = CONTAINSSTRING('_List SG'[SG] IN { "AO", "BPO","IO" },"OUT")
RETURN
IF('_List SG'[SG]=V1,V1,V2)
 

cristianml_0-1646250656737.png

 

Thanks!

1 ACCEPTED SOLUTION
ElenaN
Resolver V
Resolver V

Hello,

 

CON or OUT =
IF (
'_List SG'[SG] IN { "SC", "CON", "SI" },
"CON",
IF ( '_List SG'[SG] IN { "AO", "BPO", "IO" }, "OUT", "OTHERS" )
)

 

Best regards,

ElenaN

View solution in original post

3 REPLIES 3
ElenaN
Resolver V
Resolver V

Hello,

 

CON or OUT =
IF (
'_List SG'[SG] IN { "SC", "CON", "SI" },
"CON",
IF ( '_List SG'[SG] IN { "AO", "BPO", "IO" }, "OUT", "OTHERS" )
)

 

Best regards,

ElenaN

ElenaN
Resolver V
Resolver V

Hello,

 

You could try something like:

 

CON or OUT = 

IF (
    CONTAINSSTRING ( '_List SG'[SG], "SC" )
        || CONTAINSSTRING ( '_List SG'[SG], "CON" )
        || CONTAINSSTRING ( '_List SG'[SG], "SI" ),
    "CON",
    IF (
        CONTAINSSTRING ( '_List SG'[SG], "AO" )
            || CONTAINSSTRING ( '_List SG'[SG], "BPO" )
            || CONTAINSSTRING ( '_List SG'[SG], "IO" ),
        "OUT",
        "OTHERS"
    )
)
 
However, is it needed to use containsstring as the field SG in the print screen contains exactly the values listed? If it is not needed then you could use directly an IN list of values.
 
Best regards,
ElenaN

Hi @ElenaN ,

 

Could you share the measure with IN funcion instead of containsstring?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.