cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nicktayl
Helper I
Helper I

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

Capture.PNG 

 

In Access and Excel you can write "AND" or "OR" functions with unlimited conditions. Is this not the case in Power BI DAX "AND" functions? If this is a limitation in DAX, does anyone have a clean way to write the Excel/Access function in Power BI?

1 ACCEPTED SOLUTION
OwenAuger
Super User I
Super User I

@nicktayl

In Power BI, the DAX functions AND and OR each take exactly two arguments.

 

To handle more than two arguments, use && for "and" and || for "or" (or nest as in earlier post).

e.g. A && B && C


Owen Auger

Did I answer your question? Mark my post as a solution!

My Blog
Connect on Twitter
Connect on LinkedIn

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

In stead of " ," YOU CAN USE && AND || . tHIS WILL ALLOW TO HAVE MORE THAN TWO ARGUMENTS.

 

 

OwenAuger
Super User I
Super User I

@nicktayl

In Power BI, the DAX functions AND and OR each take exactly two arguments.

 

To handle more than two arguments, use && for "and" and || for "or" (or nest as in earlier post).

e.g. A && B && C


Owen Auger

Did I answer your question? Mark my post as a solution!

My Blog
Connect on Twitter
Connect on LinkedIn

View solution in original post

Can you write out an && example?  That looks like a better way, but I'm not quite following.  

 

Thanks!

@OwenAuger Beautiful, thanks!

 

@mmace1 

DAX:

Purchase Only Flag = If(tbl_kpi[Program]="Purchase" && tbl_kpi[Purchase Price]>0 && (tbl_kpi[Rehab Budget]=0 || isblank(tbl_kpi[Rehab Budget])),"Purchase Only",blank())

 

Access:

Purchase Only Flag: IIf([kpi].[Program]="Purchase" And [kpi].[Purchase Price]>0 And ([kpi].[Rehab Budget]=0 Or [kpi].[Rehab Budget] Is Null),"Purchase Only",Null)

mmace1
Post Prodigy
Post Prodigy

Hi, 

 

You can actually have unlimited AND/OR in DAX, you just have to write it a little differently. 

 

Specifically, you have to nest all the AND/ORs above 2.  It's kinda stupid, but it works. 

 

So say in Excel you'd write: 

 

=IF(AND(A1=1,B1=2,C1=3),"OK", "oh no")

 

In DAX you'd write

 

=IF(AND(A1=1,AND(B1=2,C1=3)),"OK","oh no")

 

Edit:  Or actually use &&, that's far better.  Or the equivalent for OR, ||

 

Well, probalby not unlimited, but I imagine as many as Excel can support.

 

Anyway, so you can have many AND/OR statements, you just have to keep nesting as you go...

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors