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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DebbieStubbs67
New Member

Nested if statment with IN claus

Hi

 

Iif i have a column with a list of codes, (eg A01, A02,A03, B01, B02, B03, C01, C02,C03), How would i create a sutom colum like

 

if code in A01, A02,A03 then A Group

if code in B01, B02, B03 then B Group

if code in C01, C02,C03) then C Group

 

I am not sure of the syntaax, In SQL I would use a case statement and in cluases, but cant work out the syntx for power BI

 

therefore making

codes    New Column

A01      A Group

A02      A Group

A03      A Group

B01      B Group

B02      B Group

B03      B Group

C01      C Group

C02     C Group

C03    C Group

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @DebbieStubbs67 
Hard coded method would be

New Column =
SWITCH (
    TRUE (),
    'Table'[Code] IN { "A1", "A2", "A3" }, "A Group",
    'Table'[Code] IN { "B1", "B2", "B3" }, "B Group",
    'Table'[Code] IN { "C1", "C2", "C3" }, "A Group"
)

Other dynamic methods could also be possible but requires real examples.

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @DebbieStubbs67 
Hard coded method would be

New Column =
SWITCH (
    TRUE (),
    'Table'[Code] IN { "A1", "A2", "A3" }, "A Group",
    'Table'[Code] IN { "B1", "B2", "B3" }, "B Group",
    'Table'[Code] IN { "C1", "C2", "C3" }, "A Group"
)

Other dynamic methods could also be possible but requires real examples.

That is Spot on, Just what I need, Many Thanks

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.