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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
UsePowerBI
Post Prodigy
Post Prodigy

Can we specify an ElseIf value in SWITCH?

Hello

 

SWITCH formula is supposed to simplify nested IFs, but can we set a value for when the value of the field does not match what we specify?

 

e.g.

The below inserts A or B if 1 or 2 respectively, but can we set it to insert "NA" for values other than 1 or 2?

 

SWITCH(Rules[Index],
1, "A",

2, "B"
)

 

Thanks

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Yes. https://dax.guide/switch/ 

 

You just add the extra parameter

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@UsePowerBI , you can use switch true

example

Ind = Switch( True()
RIGHT('Weekly Data'[Pmt_Instruction_Cde],1)="2" && 'Weekly Data'[Days from Report Date] >=0 && 'Weekly Data'[Days from Report Date] <31,"All States Overdue",
RIGHT('Weekly Data'[Pmt_Instruction_Cde],1)="2" && 'Weekly Data'[State]="CA" && 'Weekly Data'[Days from Report Date] >=90,"CA Overdue",
RIGHT('Weekly Data'[Pmt_Instruction_Cde],1)="2" && 'Weekly Data'[State]="OR" && 'Weekly Data'[Days from Report Date] >=60,"OR Overdue",
""
)

 

 

You can any number of conditions

HotChilli
Super User
Super User

Yes. https://dax.guide/switch/ 

 

You just add the extra parameter

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.