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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
san17680
Helper II
Helper II

convert if condition to switch

hi,

i have this if condition which does the job for me

offline Spend travel type = IF(AND(TABLE[Travel Type]="Air",TABLE[Online/Offline]="Offline"),TABLE[Air_Spend],

                if (and(TABLE[Travel Type]="Rail",TABLE[Online/Offline]="Offline"),TABLE[Rail Spend],

                if(and(TABLE[Travel Type]="Hotel",TABLE[Online/Offline]="Offline"),TABLE[Hotel Spend])))

 

it basically identified offline spend by travel type (air or rail or hotel)

 

Just want to convert this to switch function in power bi.

 

Please advise.

Thanks

1 ACCEPTED SOLUTION

Hello @san17680 ,

 

Yes remove the last ")"


If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




View solution in original post

5 REPLIES 5
Idrissshatila
Super User
Super User

Hello @san17680 ,

 

try the following

  • offline Spend travel type =
    SWITCH (
    TRUE (),
    TABLE[Travel Type] = "Air"
    && TABLE[Online/Offline] = "Offline", TABLE[Air_Spend],
    TABLE[Travel Type] = "Rail"
    && TABLE[Online/Offline] = "Offline",
    TABLE[Rail Spend] < TABLE[Travel Type] = "Hotel"
    && TABLE[Online/Offline] = "Offline",
    TABLE[Hotel Spend]
    )

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hi,

Thanks for your response,

it is throwing an error.

switch error.PNG

Hello @san17680 ,

 

Yes remove the last ")"


If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




oops that was oversight on my part. it worked thanks


Hi @san17680 

Remove the last extra parenthese (line: 11)

Did it work ? 👌 Mark it as a solution to help spreading knowledge 👉 A kudos would be appreciated

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors