Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
MrMP
Helper III
Helper III

Measure based on maximum of previous measure

Hi all,

I have the following structure:

ProductPriceMeasure1Measure2
AA1901200192
AA1921300192
AA193500192
AA192200192
BB9230092
BB9415092

 

I need to create a measure that finds the maximum of Measure1 and then write the right price for it in Measure2 based on Product.

 

Thank you!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @MrMP 

I am not sure if I understood your question correctly, but please check the below.

 

Picture2.png

 

Measure1 measure =
SUM('Sales'[Measure1])
 
Measure1 MAX =
MAXX ( ALLEXCEPT ( Sales, Sales[Product] ), [Measure1 measure] )
 
Price of measure1 max =
CALCULATE (
SUM ( Sales[Price] ),
FILTER (
ALLEXCEPT ( Sales, Sales[Product] ),
[Measure1 measure] = [Measure1 MAX]
)
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Use TOPN to retrieve the price corresponding to the max Measure1. The pattern is as follows,

Measure2 =
MAXX( TOPN( 1, ALL( tbl[Price] ), [Measure1] ), tbl[Price] )

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Jihwan_Kim
Super User
Super User

Hi, @MrMP 

I am not sure if I understood your question correctly, but please check the below.

 

Picture2.png

 

Measure1 measure =
SUM('Sales'[Measure1])
 
Measure1 MAX =
MAXX ( ALLEXCEPT ( Sales, Sales[Product] ), [Measure1 measure] )
 
Price of measure1 max =
CALCULATE (
SUM ( Sales[Price] ),
FILTER (
ALLEXCEPT ( Sales, Sales[Product] ),
[Measure1 measure] = [Measure1 MAX]
)
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.