cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anmolgan
Post Prodigy
Post Prodigy

How to write DAX to check MIN and MAX and fulfil condition?

I want to write a DAX for calculating 2 factors basically it goes like below

 

1st DAX

if category is MIN and Manufacturer Name is Mahindra and if Category is MAX and Manufacturer Name is Mahindra then assign 1 against MAX this goes for 1 particular CustomerSKID.

 

2nd DAX

But if Category is MIN and Manufacturer Name is not Mahindra and category is MAX and manufacturer name is Mahindra then assign 1

 

above DAX should work as on 2 different rows (what I mean to say is against each Customer SKID both DAX will assign either 1 or blank.

 

Last case can be if Category is MAX and there is no MIN as per that particular category then assign Blank

 

how can I embed all the above conditions in the dataset, for now I have wirtten below DAX's but these do not satisfy the above conditions and fails and certian point.

acquisation = var val= CALCULATE(MAX(data_3months[PurchaseDate]), ALLEXCEPT(data_3months, data_3months[CustomerSKID]))

return SWITCH( TRUE(),
data_3months[Category]= "MIN" && data_3months[ManufacturerName]<>"Mahindra", "1")
 
Loyalty1 = var val= CALCULATE(MAX(CustTractorOwned[PurchaseDate]), ALLEXCEPT(CustTractorOwned, CustTractorOwned[CustomerSKID]))

return SWITCH( TRUE(),
CustTractorOwned[Category]= "MIN" && CustTractorOwned[ManufacturerName]="Mahindra", "1")

Anmolgan_0-1618930549800.png

 

1 REPLY 1
v-lionel-msft
Community Support
Community Support

Hi @Anmolgan ,

 

Please provide sample data and expected output.

 

Best regards,
Lionel Chen

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

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

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors