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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
eilidh3
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
az38
Community Champion
Community Champion

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
eilidh3
Frequent Visitor

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

jessegorter
Helper I
Helper I

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.

az38
Community Champion
Community Champion

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
HotChilli
Super User
Super User

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.

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors