March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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:
Solved! Go to Solution.
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
Thank you all for your help. Ive never used SWITCH before but it was very easy!!
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.
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
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
15 | |
12 | |
9 | |
8 |
User | Count |
---|---|
41 | |
32 | |
29 | |
12 | |
12 |