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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.