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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Marlonrb
Frequent Visitor

IF - OR Formula in Add Custom Column

I'm trying to use the IF function with OR operation in custom formula for new column but I'm not sure about the correct syntax or rules to include this new logic.

 

If I use only the IF function its work well, but I would like to include OR syntax at the formula and returns the error message below:

         Expression.Error: We cannot convert the value true to type Function.
         Details:
                   Value=TRUE
                   Type=Type

 

I've already try to use double pipe symbol "||" , I tryed "OR", "IF OR"...

example:

if (([Cat14]="B04") || ([Cat14]="B03")) then "GRP1"
else if (([Cat14]="B05" ) || ( [Cat14]="B09")) then "GRP2"
else "Geral"

 

Anybody knows if is possible to use OR operation together with IF formula, or smth like that...?

 

Thanks

Marlon B.

1 ACCEPTED SOLUTION
curth
Power BI Team
Power BI Team

The "or" has to be lower-case:

 

let
    a = Table.FromColumns({{"B04", "B09", "B10"}}, {"Cat14"}),
    b = Table.AddColumn(a, "Calc",
        each if ([Cat14]="B04" or [Cat14]="B03") then "GRP1"
        else if ([Cat14]="B05" or [Cat14]="B09") then "GRP2"
        else "Geral")
in
    b

View solution in original post

4 REPLIES 4
curth
Power BI Team
Power BI Team

The "or" has to be lower-case:

 

let
    a = Table.FromColumns({{"B04", "B09", "B10"}}, {"Cat14"}),
    b = Table.AddColumn(a, "Calc",
        each if ([Cat14]="B04" or [Cat14]="B03") then "GRP1"
        else if ([Cat14]="B05" or [Cat14]="B09") then "GRP2"
        else "Geral")
in
    b
Greg_Deckler
Community Champion
Community Champion

if (([Cat14]="B04") || ([Cat14]="B03"), "GRP1", IF (([Cat14]="B05" ) || ( [Cat14]="B09"),"GRP2","Geral"))

 

I might have a paren mismatch somewhere



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

err OR.JPGNot yet.

When I click "show error", it Hint the "||" symbol as possible error 😕

This formula works for you smoupre?

 

Many tks.

My bad, when you said "custom column", I was thinking that you were creating a custom column in Power BI Desktop once you already loaded the data so I gave you the DAX syntax. Looks like you wanted the "M" syntax. See @curth response for the M syntax.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors