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
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
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.