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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Using SWITCH to return "Blank" from multiple column criteria

Hi All

Hope you can help, i have a SWITCH(TRUE() expression which is also using the SEARCH function to return values depending on their result in particular columns. I am trying to include a multiple SWITCH condition which will return the word "Blank" if two both columns have empty cells on that row.

The below expression is how i have my expression working so far, can anyone help whereby it returns the word "Blank" if columns '[LeadSourceLvl1_Name]' & '[LeadSourceLvl2_Name]' are both empty?

 

Thanks in advance for your help - see below for current expression as reference 

Regards

Dan

 

Marketing Grouping = SWITCH(TRUE(),SEARCH("TV",'Lead'[LeadSourceLvl1_Name],1,0)>0,"TV",SEARCH("TV Advert",'Lead'[LeadSourceLvl2_Name],1,0)>0,"TV",SEARCH("Google",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Google",SEARCH("Google",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Google",SEARCH("Direct Mail",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Direct Mail",LEFT('Lead'[LeadSourceLvl2_Name],2)="DM","Direct Mail",SEARCH("Insert",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Insert",LEFT('Lead'[LeadSourceLvl2_Name],1)="N","Insert",SEARCH("Recommended by Friend",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Rec By Friend",SEARCH("Recommendation",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Rec By Friend",SEARCH("Facebook",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Facebook",SEARCH("Youtube",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Youtube",SEARCH("Youtube",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Youtube",SEARCH("Web Site",'Lead'[LeadSourceLvl1_Name],1,0)>0&&'Lead'[LeadSourceLvl2_Name]=BLANK(),"Blank",SEARCH("Senior Response",'Lead'[LeadSourceLvl1_Name],1,0)>0&&'Lead'[LeadSourceLvl2_Name]=BLANK(),"Blank","Other")
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , added condition at start, see if that can help

 

SWITCH(TRUE(),
isblank('Lead'[LeadSourceLvl1_Name]) && isblank('Lead'[LeadSourceLvl2_Name]), blank(),
SEARCH("TV",'Lead'[LeadSourceLvl1_Name],1,0)>0,"TV"
,SEARCH("TV Advert",'Lead'[LeadSourceLvl2_Name],1,0)>0,"TV",
SEARCH("Google",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Google",
SEARCH("Google",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Google",
SEARCH("Direct Mail",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Direct Mail",
LEFT('Lead'[LeadSourceLvl2_Name],2)="DM","Direct Mail",
SEARCH("Insert",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Insert",LEFT('Lead'[LeadSourceLvl2_Name],1)="N","Insert",SEARCH("Recommended by Friend",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Rec By Friend",SEARCH("Recommendation",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Rec By Friend",SEARCH("Facebook",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Facebook",SEARCH("Youtube",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Youtube",SEARCH("Youtube",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Youtube",SEARCH("Web Site",'Lead'[LeadSourceLvl1_Name],1,0)>0&&'Lead'[LeadSourceLvl2_Name]=BLANK(),"Blank",SEARCH("Senior Response",'Lead'[LeadSourceLvl1_Name],1,0)>0&&'Lead'[LeadSourceLvl2_Name]=BLANK(),"Blank","Other")

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , added condition at start, see if that can help

 

SWITCH(TRUE(),
isblank('Lead'[LeadSourceLvl1_Name]) && isblank('Lead'[LeadSourceLvl2_Name]), blank(),
SEARCH("TV",'Lead'[LeadSourceLvl1_Name],1,0)>0,"TV"
,SEARCH("TV Advert",'Lead'[LeadSourceLvl2_Name],1,0)>0,"TV",
SEARCH("Google",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Google",
SEARCH("Google",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Google",
SEARCH("Direct Mail",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Direct Mail",
LEFT('Lead'[LeadSourceLvl2_Name],2)="DM","Direct Mail",
SEARCH("Insert",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Insert",LEFT('Lead'[LeadSourceLvl2_Name],1)="N","Insert",SEARCH("Recommended by Friend",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Rec By Friend",SEARCH("Recommendation",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Rec By Friend",SEARCH("Facebook",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Facebook",SEARCH("Youtube",'Lead'[LeadSourceLvl1_Name],1,0)>0,"Youtube",SEARCH("Youtube",'Lead'[LeadSourceLvl2_Name],1,0)>0,"Youtube",SEARCH("Web Site",'Lead'[LeadSourceLvl1_Name],1,0)>0&&'Lead'[LeadSourceLvl2_Name]=BLANK(),"Blank",SEARCH("Senior Response",'Lead'[LeadSourceLvl1_Name],1,0)>0&&'Lead'[LeadSourceLvl2_Name]=BLANK(),"Blank","Other")

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
Anonymous
Not applicable

That worked perfectly, thankyou for your help, yes adding that part of the expression at the start and not at the end seemed to help, many thanks

 

Dan

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors