cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vagelis
Frequent Visitor

Custom Column error

I have put together the following custom column in power query editor, and it generates a "Token ',' expected" error on it, and I cant actually see where I have went wrong with the code, show error highlights the first IN. Thanks if anyone has any advice to help!

 

  SWITCH(TRUE(),
        [priority_cd] IN {"A_1HRE", "B_6HRE"} 
            AND [class] IN {"3", "4", "8"} 
            AND ISNULL([need_cat], "AAA") <> "GAR" 
            AND [ord_status] <> "CAN" 
            AND ISNULL([ord_stage], "AAA") NOT IN {"CNA", "CNI", "CTR", "CWA", "DUP", "TRC"}, "Emergency",
        [priority_cd] NOT IN {"A_1HRE", "B_6HRE"} 
            AND [class] IN {"3", "4", "8"} 
            AND ISNULL([need_cat], "AAA") <> "GAR" 
            AND [ord_status] <> "CAN" 
            AND ISNULL([ord_stage], "AAA") NOT IN {"CNA", "CNI", "CTR", "CWA", "DUP", "TRC"}, "NonEmergency",
        [class] NOT IN {"3", "4", "8"} 
            OR ISNULL([need_cat], "AAA") = "GAR" 
            OR [ord_status] = "CAN" 
            OR ISNULL([ord_stage], "AAA") IN {"CNA", "CNI", "CTR", "CWA", "DUP", "TRC"}, "Other"
    )

 

1 ACCEPTED SOLUTION
sendilc
Frequent Visitor

Hi, 

 

I am not sure if PowerQuery supports SWITCH, you will need to used nested if. 

Alternatively you can use Data view and write a DAX function to insert a new column; the above query should work if replace AND by && , OR by ||

 

Regards

 

View solution in original post

1 REPLY 1
sendilc
Frequent Visitor

Hi, 

 

I am not sure if PowerQuery supports SWITCH, you will need to used nested if. 

Alternatively you can use Data view and write a DAX function to insert a new column; the above query should work if replace AND by && , OR by ||

 

Regards

 

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors
Top Kudoed Authors