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
JoanCampbell
Frequent Visitor

IF statement for 3 criteria

Value = IF(AND((Merchandising[Merchandizing Type]="Pack out to shelf" || Merchandising[Merchandizing Type]="Pack out to Exsisting Display"||Merchandising[Merchandizing Type]="Pack out to new display"),(Merchandising[Qty]*(LOOKUPVALUE('Price List'[Unit Price],'Price List'[Item UPC#],Merchandising[UPC from List]))))

 

I have three criteria Merchandising type= "pack out to shelf", "pack out to existing display" and "pack out to new display"  This is how I wrote the formula, but it gives me an error of having more than 2 arguments.  

 

Help!

What am I doing wrong? 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @JoanCampbell ,

 

if you are using the DAX and want to use AND then you have to write your DAX like so:

...
IF(
AND( AND( condition1 , condition2 ) , condition3 )
, TRUE branch
, FALSE branch
)
...

using DAX this will work as well, keep in mind that || means OR and && means AND

...
IF(
( condition1 && condition2 && condition3 )
, TRUE branch
, FALSE branch
)
...

 

Hopefully, this provides the missing link, and helps to tackle your challenge.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @JoanCampbell ,

 

This is a sample of data that I understand, I don't know if it's right.

6.png

From the data on the figure, only [Qty] and [Price] of A can be multiplied.

 

You should copy a category column first, and then pivot table as follows.

10.png8.png9.png

 

 

Measure

Measure = IF(CALCULATE(DISTINCTCOUNT(Merchandising[Merchandizing Type]),ALLEXCEPT(Merchandising,Merchandising[Category]))=3,MAX('Merchandising'[Qty])*MAX('Merchandising'[Price]))

11.png

 

Calculated column

Column = IF(CALCULATE(DISTINCTCOUNT(Merchandising[Merchandizing Type]),ALLEXCEPT(Merchandising,Merchandising[Category]))=3,[Qty]*[Price])

13.png

 

If my understanding is wrong, provide some sample data and expected results?

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

TomMartens
Super User
Super User

Hey @JoanCampbell ,

 

if you are using the DAX and want to use AND then you have to write your DAX like so:

...
IF(
AND( AND( condition1 , condition2 ) , condition3 )
, TRUE branch
, FALSE branch
)
...

using DAX this will work as well, keep in mind that || means OR and && means AND

...
IF(
( condition1 && condition2 && condition3 )
, TRUE branch
, FALSE branch
)
...

 

Hopefully, this provides the missing link, and helps to tackle your challenge.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Value = IF((Merchandising[Merchandizing Type]="Pack Out to Shelf"&&Merchandising[Merchandizing Type]="Pack Out to Existing Display"&&Merchandising[Merchandizing Type]="Pack Out to New Display"),(Merchandising[Qty]*Merchandising[Price])) 
 
comes back blank. 

Hey @JoanCampbell ,

 

you have to use || instead of &&. Using && means AND, the condition asks for a row where the same column has to have 3 different values at the same time.

 

Please excuse, in my 1st reply to your question I replaced the || by && as I was concentrating more on the combination of three conditions as of the content.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.