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
icdns
Post Patron
Post Patron

SWITCH STATEMENT

Hello,

 

Could someone help me in deriving result A to result B? Wherein I wanted to fall General Office in Small Business (see result B) 

I have 2 columns and I have used a SWITCH STATEMENT but it's not working 😞 

 

I'm getting below result: 

 

RESULT
SEG_MAJ_GRPSEG_DESC
CORP> 500
CORPNATIONAL OFFICE
HOME 
HOMELOCAL OFFICE
HOMEHOME OFFICE
SMALL BUSINESS< 500
N/AUNDETERMINED 

 

Here's my calculated column:

SEG_MAJ_GRP_SWITCH = IF(TABLE[SEG_MAJ_GRP] = "CORPORATE", SWITCH(TABLE[SEG_DESC], ">500",">500","NATIONAL OFFICE","NATIONAL OFFICE"),
 
IF(TABLE[SEG_MAJ_GRP] ="SMALL BUSINESS",SWITCH(TABLE[SEG_DESC], "< 500","< 500","GENERAL OFFICE","GENERAL OFFICE"),
 
IF(TABLE[SEG_MAJ_GRP] = "HOME OFFICE",SWITCH(TABLE[SEG_DESC], "LOCAL OFFICE","LOCAL OFFICE","HOME OFFICE","HOME OFFICE"),"N/A")))
 
EXAMPLE SCENARIO

 

RESULT A
SEG_MAJ_GRPSEG_DESC
CORP> 500
CORPNATIONAL OFFICE
HOMEGENERAL OFFICE
HOMELOCAL OFFICE
HOMEHOME OFFICE
SMALL BUSINESS< 500
N/AUNDETERMINED 

 

Desired Result:

 

RESULT B
SEG_MAJ_GRPSEG_DESC
CORP> 500
CORPNATIONAL OFFICE
SMALL BUSINESSGENERAL OFFICE
HOMELOCAL OFFICE
HOMEHOME OFFICE
SMALL BUSINESS< 500
N/AUNDETERMINED 

 

Thanks a lot! 😄  

 
 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

@icdns , 

 

Create another calculated column for that. Liek below. 

manikumar34_0-1602575977198.png

 

SEG_MAJ_GRP1 = IF(AND('Table (2)'[SEG_MAJ_GRP] = "HOME",'Table (2)'[SEG_DESC]="GENERAL OFFICE"),SWITCH('Table (2)'[SEG_MAJ_GRP], "HOME","SMALL BUSINESS"),'Table (2)'[SEG_MAJ_GRP])
 
If you think this is helpful Please Accept as Solution and Leave a like.
 
Regards, 
Manikumar




If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




View solution in original post

11 REPLIES 11
manikumar34
Solution Sage
Solution Sage

@icdns , 

 

Can you share some sample data or PBIX with Sample data??

 

Reards, 

Manikumar





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Hi @manikumar34 ,

 

Sorry i cant paste the file here. but this is just my dataset 

 

Thank you!

 

Table Name: Table

 

SEG_MAJ_GRPSEG_DESCCUSTOMER_COUNT
CORP> 500169
CORPNATIONAL OFFICE19
HOMEGENERAL OFFICE3832
HOMELOCAL OFFICE169
HOMEHOME OFFICE110933
MEKO USEMEKO USE0
N/AUNDETERMINED1
SMALL BUSINESS< 5001359

@icdns , 

 

I'm not clear but if you are looking something like below, Use the provided DAX.

manikumar34_0-1602574534305.png

SEG_MAJ_GRP_SWITCH = IF('Table (2)'[SEG_MAJ_GRP] = "CORP", SWITCH('Table (2)'[SEG_DESC], "> 500","> 500","NATIONAL OFFICE","NATIONAL OFFICE"),
 
IF('Table (2)'[SEG_MAJ_GRP] ="SMALL BUSINESS",SWITCH('Table (2)'[SEG_DESC],"GENERAL OFFICE","GENERAL OFFICE","< 500","< 500"),
 
IF('Table (2)'[SEG_MAJ_GRP] = "HOME",SWITCH('Table (2)'[SEG_DESC], "LOCAL OFFICE","LOCAL OFFICE","HOME OFFICE","HOME OFFICE","GENERAL OFFICE"),"N/A")))
 
Regards, 
Manikumar

 

 





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Hi @manikumar34 ,

 

Very near!! 😄 But is it possible instead of HOME, GENERAL OFFICE will fall under SMALL BUSINESS? (See font in Red)

Untitled.png

 

Thanks alot!!! 🙂 

@icdns , 

 

Create another calculated column for that. Liek below. 

manikumar34_0-1602575977198.png

 

SEG_MAJ_GRP1 = IF(AND('Table (2)'[SEG_MAJ_GRP] = "HOME",'Table (2)'[SEG_DESC]="GENERAL OFFICE"),SWITCH('Table (2)'[SEG_MAJ_GRP], "HOME","SMALL BUSINESS"),'Table (2)'[SEG_MAJ_GRP])
 
If you think this is helpful Please Accept as Solution and Leave a like.
 
Regards, 
Manikumar




If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




it is now working! Thank you! 

@icdns 

 

Awesome, you got the Answer you are looking for. 

 

Your Kudos will be Appreciated. 🙂

 

Regards, 

Manikumar

 

 





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




amitchandak
Super User
Super User

@icdns , Try like

 

SEG_MAJ_GRP_SWITCH = IF(TABLE[SEG_MAJ_GRP] = "CORPORATE",
SWITCH(true(),
TABLE[SEG_DESC], ">500",">500"
,"NATIONAL OFFICE","NATIONAL OFFICE"
),

 

///and add on

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak , 

 

When i tried to use the logic, it returns below error: 

 

What does this mean? 😞 Thank you for the help!

 

icdns_0-1602568658978.png

 

@icdns , My bad , something like this

 

SEG_MAJ_GRP_SWITCH = IF(TABLE[SEG_MAJ_GRP] = "CORPORATE",
SWITCH(true(),
TABLE[SEG_DESC]= "500",">500",
TABLE[SEG_DESC]= "NATIONAL OFFICE","NATIONAL OFFICE"
),

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, @amitchandak ,

 

Tried your column. But it gives me the same result 😞 

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.