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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Elios
Regular Visitor

Convert Excel functions to DAX

Hello there,

 

I am a new user of power BI, I have quite the complex formula in excel that return conditional values. I tried to put it in Power BI however the error:

"Too many arguments were passed to the OR function. The maximum argument count for the function is 2." happens.

 

While this works perfectly in Excel. Could you help me see what could be changes in it and convert it in DAX ? Thank you

 

The Excel forumula is:

 

=IF([@[Aa]]="YES";IF(OR(ISNUMBER(SEARCH("TM TD";[@[Bb]];1));[@[Bb]]="TM BOLOGNA";[@[Bb]]="TM TOLOS";[@[Bb]]="PROJECT");IF(AND([@[Cc]]=0;OR([@[Dd]]="";[@[Ee]]=""));"valid";"conflict");IF(AND([@[Cc]]=1;AND([@[Dd]]>0;[@[Ee]]>0));"conflict";IF(OR([@[Ff]]=1;[@[Gg]]=1);"valid";IF(AND([@[Hh]]="SECTOR";[@[Ii]]=[@[Jj]];[@[Jj]]=[@[Kk]]);"sector ag";""))));"N/A")

 

The current DAX formula that gives me the error is :

 

Sitation = IF(Sheet1[Aa]="YES",

 

IF

(OR

(ISNUMBER

(SEARCH

("TM TD",Sheet1[Bb],1,"0")),

Sheet1[Bb]="TM BOLOGNA",Sheet1[Bb]="TM TOLOS",Sheet1[Bb]="PROJECT"),

IF

(AND

(Sheet1[Cc]=0,

OR(Sheet1[Dd]="",Sheet1[Ee]="")

),"valid","conflict"),

 

IF

(AND

(Sheet1[Cc]=1,

 

AND

(Sheet1[Dd]>0,Sheet1[Ee]>0)),

 

"conflict",

IF(

OR(

Sheet1[Ff]=1,Sheet1[Gg]=1)

,"valid",IF

(AND

(Sheet1[Hh]="SECTOR",Sheet1[Ii]=Sheet1[Jj],Sheet1[Jj]=Sheet1[Kk]),"sector ag","")))),

 

"N/A")

 

1 ACCEPTED SOLUTION
nandic
Memorable Member
Memorable Member

@Elios , @parry2k  mentioned below matching syntax:

|| -> OR

&& -> AND
You can use OR/AND when you compare 2 arguments, and you should use 

|| / && when having more than 2 arguments

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@Elios yes 


|| -> OR

&& -> AND



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

nandic
Memorable Member
Memorable Member

Hi @Elios ,
It seems your are passing multiple conditions to OR function? OR function accepts only 2 parameters.
If you need multiple conditions in OR function, use this syntax:
If(Table[Criteria1] = "A" || Table[Criteria2] = "B" || Table[Criteria3] = "C" || ...

Regards,
Nemanja Andic

Thank you that seems to be what I need, what are the || ? Do they play a similar role to the OR function ?

 

Also I have a similar problem with the AND function that is less flexible than on excel. Do you have any idea how to replace it with something that can accept more than 2 parameters ?

nandic
Memorable Member
Memorable Member

@Elios , @parry2k  mentioned below matching syntax:

|| -> OR

&& -> AND
You can use OR/AND when you compare 2 arguments, and you should use 

|| / && when having more than 2 arguments

parry2k
Super User
Super User

@Elios It will be much easier if you share sample data and the expected output of this column. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.