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
Anonymous
Not applicable

measure error

My measure as below. 
 
Measure 2 = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start (Date)]),
FILTER ('Before 2021',
AND ( YEAR(DATEVALUE('Before'[Start(Date)])) <> 2021 , MONTH(DATEVALUE('Before'[Start(Date)])) <> 1 , 'Before'[Start (Date)] <> BLANK())
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )
 
It error Too many arguments were passed to the AND function. The maximum argument count for the function is 2.
1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

AND() only takes two arguments. If you want to use more then you need to use &&

 

Measure 2 = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start (Date)]),
FILTER ('Before 2021',
 ( YEAR(DATEVALUE('Before'[Start(Date)])) <> 2021 && MONTH(DATEVALUE('Before'[Start(Date)])) <> 1  && 'Before'[Start (Date)] <> BLANK())
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @Anonymous 

AND() only takes two arguments. If you want to use more then you need to use &&

 

Measure 2 = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start (Date)]),
FILTER ('Before 2021',
 ( YEAR(DATEVALUE('Before'[Start(Date)])) <> 2021 && MONTH(DATEVALUE('Before'[Start(Date)])) <> 1  && 'Before'[Start (Date)] <> BLANK())
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


mahoneypat
Employee
Employee

You can either nest multiple ANDs together or (easier) just use && between each term instead of AND.  Also, you should avoid filtering the whole table.  It is better practice to use this approach

 

FILTER(ALL('Before'[Start(date)]), ... && ... &&... )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.