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
CloudMonkey
Post Prodigy
Post Prodigy

Dax for maxif

Hi,

 

Please can you tell me the dax formula to find the column "Maximum Sales In Area"? (for each row it should find the maximum number of sales for the branch with the most sales in the same area)

 

Branch | Area | Sales | Maximum Sales In Area

1 | North | 20 | 40

2 | North | 40 | 40

3 | North | 35 | 40

4 | South | 5 | 12

5 | South | 12 | 12

6 | South | 8 | 12

 

Thanks,

 

CM

 

p.s. I've tried the CALCLATE function with MAX and FILTER but it doesn't allow me to specifiy a different value condition for each row.

 

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@CloudMonkey

 

 

Hi, lets try with:

Calculated Column

 

MaximumSalesinArea =
CALCULATE (
    MAX ( Table2[Sales] );
    FILTER ( Table2; Table2[Area] = EARLIER ( Table2[Area] ) )
)

 

Regards

 

Victor

Lima - Peru




Lima - Peru

View solution in original post

4 REPLIES 4
tecumseh
Helper II
Helper II

@Vvelarde 

I built this faithfully to understand Earlier.
I am receiving an error message:

EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

My DAX:

MaximumSalesInArea =

CALCULATE(

    MAX( Table2[Sales] ),

    FILTER(

        Table2,

        Table2[Area] = EARLIER( Table2[Area] )

    )

)

Hi,

Write it as a calculated column formula (not as a measure).


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
johnajoseph
Regular Visitor

Hmm... for me, those semicolons needed to be commas. But otherwise worked.

Vvelarde
Community Champion
Community Champion

@CloudMonkey

 

 

Hi, lets try with:

Calculated Column

 

MaximumSalesinArea =
CALCULATE (
    MAX ( Table2[Sales] );
    FILTER ( Table2; Table2[Area] = EARLIER ( Table2[Area] ) )
)

 

Regards

 

Victor

Lima - Peru




Lima - Peru

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.