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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rsty
New Member

New column based on values/string of two other columns

Im new to PBI and trying to recreate an expression from another package and having some issues due to inexperience with PBI.

Im trying to create a new column with string "pass" or "fail".Below is generaly what im trying to do

new =

if(

[col01] = ''abc'' && [col02] > 20, ''fail'', elseif

[col01] = ''def'' && [col02] > 50, ''fail'', elseif

[col01] = ''ghi'' && [col02] > 100, ''fail'', pass

)

 

Questions:

1. Is there an elseif type function in PBI?

2. Without trying to nest and using the follwing expression i get the following warning.

 

new = IF( [col01] = ''abc'' && [col02] > 20, ''fail'', "pass")

DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

 

is there a solution to this?

 

Advice,  links to pages that may help greatly appreciated. rsty 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @rsty 
Yes you can use SWITCH function and no need to type "elseif" as the comma " , " means "Then", "elseif" or "else" depending on its position. Please use

=
SWITCH (
    TRUE (),
    [col01] = "abc"
        && [col02] > 20, "fail",
    [col01] = "def"
        && [col02] > 50, "fail",
    [col01] = "ghi"
        && [col02] > 100, "fail",
    "pass"
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @rsty 
Yes you can use SWITCH function and no need to type "elseif" as the comma " , " means "Then", "elseif" or "else" depending on its position. Please use

=
SWITCH (
    TRUE (),
    [col01] = "abc"
        && [col02] > 20, "fail",
    [col01] = "def"
        && [col02] > 50, "fail",
    [col01] = "ghi"
        && [col02] > 100, "fail",
    "pass"
)

Totally worked. Thanks

Jihwan_Kim
Super User
Super User

Hi,

Please share your sample pbix file's link, and then I can try to check what is the problem having an error message.

->Please check the data type of the [col02] column. -> May be text data type. -> Change this to Number data type in Power Query Editor.

 

 

Please try the calculated column like below.

 

new column CC =
SWITCH (
    TRUE (),
    [col01] = "abc"
        && [col02] > 20, "fail",
    [col01] = "def"
        && [col02] > 50, "fail",
    [col01] = "ghi"
        && [col02] > 100, "fail",
    "Pass"
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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