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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.


Go to My LinkedIn Page


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.


Go to My LinkedIn Page


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.