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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DM_95
Helper I
Helper I

Measure for Highest value and 2nd highest value of column

Hi,

 

I want to create a measure for the highest value and 2nd highest value of Delivery Country. In the matrix below, Net Sales PY ('Sales' [Net Sales PY]) are displayed by Width ('Product'[Width]) and by Delivery Country ('Address'[Country ISO]). What I try to create in this matrix is a column next to Net Sales PY with the highest value of Delivery Country ('Address'[Country ISO]). So, in this case for Width=320, Delivery Country "DE" needs to be shown (Other countries as Blank()). I would also need an extra column with 2nd highest value of Delivery Country ('Address'[Country ISO]). So, in this case for Width=320, Delivery Country "BE" needs to be shown.

It needs to be dynamic. So when I select other customers, it needs to take into account all possible Delivery Countries.

 

DM_95_0-1668082912024.png

2 REPLIES 2
DM_95
Helper I
Helper I

@amitchandak , when I create your measure it shows exactly the same values as [Net Sales PY] because it's already sorted by Width and Country ISO. What I'm trying to get is the Country ISO for the maximum value. For example, [Net Sales PY] of Width "320" and Country ISO "DE" is 237.338,73 --> measure needs to show the max value of Country ISO. So, "DE" in this case. The second measure needs to do the same but for the 2nd highest value of Country ISO ("BE" in this case).

 

Thanks in advance!

amitchandak
Super User
Super User

@DM_95 , Try a measure like

 

calculate([Net Sales PY], TOPN(2, allselected('Address'[Country ISO]), [Net Sales PY],desc), values('Address'[Country ISO]))

 

TOPN: https://youtu.be/QIVEFp-QiOk

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.