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

Too many arguments were passed to the IF function.

Im looking to create a new column with short form of our business names.  We have 22 business units.  I have tried the below however it wont allow me and comes up with the following error ' Too many arguments were passed to the IF function.  The maximum argument count for the function is 3.

 

My DAX code is as follows:

 

Business Unit NEW = IF([Business Unit] = "Civil Engineering" || [Business Unit] = "Civil Engineering Small Works","Civils", IF([Business Unit] = "Construction Central" || [Business Unit] = "Construction Small Works Central", "Central ", IF([Business Unit] = "Construction West" || "Robertson Construction Small Works West", "West", IF([Business Unit]="Construction Group", "Group", IF([Business Unit] = "Construction East" || "Construction Small Works East", "East", IF([Business Unit] = "Construction North" || "Construction Small Works North", "North", IF([Business Unit] = "Construction Northern", "Construction Small Works Northern", "Northern", IF([Business Unit]= "Engineering Services", "M&E", IF([Business Unit] = "Facilities Management", "FM", IF([Business Unit] = "Partnership Homes", "Homes", IF([Business Unit] = "Specialist Division", "Specialist")
 
Any help anyone can give would be much appreciated.
 
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
Super User II
Super User II

Re: Too many arguments were passed to the IF function.

Hi @eilidh3 

Your statement will feel itself better if you try such

IF([Business Unit] = "Civil Engineering" || [Business Unit] = "Civil Engineering Small Works","Civils", 
IF([Business Unit] = "Construction Central" || [Business Unit] = "Construction Small Works Central", "Central ", 
IF([Business Unit] = "Construction West" || [Business Unit] = "Robertson Construction Small Works West", "West", 
IF([Business Unit]= "Construction Group", "Group", 
IF([Business Unit] = "Construction East" || [Business Unit] = "Construction Small Works East", "East", 
IF([Business Unit] = "Construction North" || [Business Unit] = "Construction Small Works North", "North", 
IF([Business Unit] = "Construction Northern"|| [Business Unit] = "Construction Small Works Northern", "Northern", 
IF([Business Unit]= "Engineering Services", "M&E", 
IF([Business Unit] = "Facilities Management", "FM", 
IF([Business Unit] = "Partnership Homes", "Homes", 
IF([Business Unit] = "Specialist Division", "Specialist"
)))))))))))

 

But the best option is using switch

SWITCH([Business Unit],
"Civil Engineering", "Civils",
"Civil Engineering Small Works","Civils", 
"Construction Central", "Central ", 
"Construction Small Works Central", "Central ", 
"Construction West", "West",
"Robertson Construction Small Works West", "West", 
"Construction Group", "Group", 
"Construction East", "East", 
"Construction Small Works East", "East", 
"Construction North", "North", 
"Construction Small Works North", "North", 
"Construction Northern", "Northern", 
"Construction Small Works Northern", "Northern", 
"Engineering Services", "M&E", 
"Facilities Management", "FM", 
"Partnership Homes", "Homes", 
"Specialist Division", "Specialist",
"Undefined"
)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

LinkedIn


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

5 REPLIES 5
Super User I
Super User I

Re: Too many arguments were passed to the IF function.

There are quite a few places in the statement where it stops explicitly testing against the column e.g.

IF([Business Unit] = "Construction East" || "Construction Small Works East", "East"

 

the code needs to do tests as in the first line.

 

 

Also check out the switch statement to save typing.

Peter_R Regular Visitor
Regular Visitor

Re: Too many arguments were passed to the IF function.

I actually just posted an example of using SWITCH to avoid those nested IFs here in case you'd like pattern:
https://community.powerbi.com/t5/DAX-Commands-and-Tips/0-not-recognized-as-a-number/m-p/903510#M8349

Super User II
Super User II

Re: Too many arguments were passed to the IF function.

Hi @eilidh3 

Your statement will feel itself better if you try such

IF([Business Unit] = "Civil Engineering" || [Business Unit] = "Civil Engineering Small Works","Civils", 
IF([Business Unit] = "Construction Central" || [Business Unit] = "Construction Small Works Central", "Central ", 
IF([Business Unit] = "Construction West" || [Business Unit] = "Robertson Construction Small Works West", "West", 
IF([Business Unit]= "Construction Group", "Group", 
IF([Business Unit] = "Construction East" || [Business Unit] = "Construction Small Works East", "East", 
IF([Business Unit] = "Construction North" || [Business Unit] = "Construction Small Works North", "North", 
IF([Business Unit] = "Construction Northern"|| [Business Unit] = "Construction Small Works Northern", "Northern", 
IF([Business Unit]= "Engineering Services", "M&E", 
IF([Business Unit] = "Facilities Management", "FM", 
IF([Business Unit] = "Partnership Homes", "Homes", 
IF([Business Unit] = "Specialist Division", "Specialist"
)))))))))))

 

But the best option is using switch

SWITCH([Business Unit],
"Civil Engineering", "Civils",
"Civil Engineering Small Works","Civils", 
"Construction Central", "Central ", 
"Construction Small Works Central", "Central ", 
"Construction West", "West",
"Robertson Construction Small Works West", "West", 
"Construction Group", "Group", 
"Construction East", "East", 
"Construction Small Works East", "East", 
"Construction North", "North", 
"Construction Small Works North", "North", 
"Construction Northern", "Northern", 
"Construction Small Works Northern", "Northern", 
"Engineering Services", "M&E", 
"Facilities Management", "FM", 
"Partnership Homes", "Homes", 
"Specialist Division", "Specialist",
"Undefined"
)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

LinkedIn


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

jessegorter Frequent Visitor
Frequent Visitor

Re: Too many arguments were passed to the IF function.

You use way too many arguments indeed. You have 3 parameters, the first one being what is tested, the second one if the first resolves to true, and the third if it resolves to false. So you will either need to use nesting if's, or the switch as shown above.

eilidh3 Frequent Visitor
Frequent Visitor

Re: Too many arguments were passed to the IF function.

Thank you all for your help.  Ive never used SWITCH before but it was very easy!! 

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors