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
kan
Helper I
Helper I

SWITCH or IF in calculated columns

Hi,

 I want to create a calculated column named Category from  two tables

DWSP 

DInOutdoor

 

DWSP table has column named WSP 

DInOutdoor has column named InOutdoor

 

Following is the condition I need to implement.

 

If WSP = ‘STG’ then ‘Strategic’

Else if InOutdoor = ‘Indoor’ then ‘Indoor’

Else if InOutdoor = ‘Oudoor’ then ‘Oudoor’

Else ‘Unknown’

 

I know how to use switch with single table.Can someone help me how to write above condition when using tables.

 

Thanks..

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @kan

 

You need to use SWITCH().

 

New col = 
VAR  vInOut = RELATED(DInOutdoor[InOutdoor])
RETURN
SWITCH ( TRUE(),
          Dwsp[Wsp]= "STG".Strategic,
         vInOut = "Indoor","Indoor",
         vInout= "Outdoor","Outdoor",
         "Unknown")

 

Thanks

Raj

View solution in original post

Thanks @AnonymousRaj for the solution.

View solution in original post

5 REPLIES 5
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @kan,

 

In which table you need to create such a calculated column? Is there any relationship between these two tables? Please provide dummy data to illustrate your scenario.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @kan

 

You need to use SWITCH().

 

New col = 
VAR  vInOut = RELATED(DInOutdoor[InOutdoor])
RETURN
SWITCH ( TRUE(),
          Dwsp[Wsp]= "STG".Strategic,
         vInOut = "Indoor","Indoor",
         vInout= "Outdoor","Outdoor",
         "Unknown")

 

Thanks

Raj

What if the DInOutdoor table is on the Many side? How to use RelatedTable then?

Thanks Raj for the solution.

Thanks @AnonymousRaj for the solution.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.