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
zausten
Helper I
Helper I

Create measure to get min value of a selected dimension using another value of that dimension

Hi ,

 

I am trying to get the min value of one dimension based on selecting another value of that dimension through a common dimension. 

e.g. I have simple table with date, car, colour and amount.   The car can have multiple colours. Green is the cheapest.  I select red in a filter so I can display the cost of red in one visual, but I also want to see the cheapest for comparision.

 

My approach is get the car first of the selected colour, then get the list of all colours associated with that car, then get try to get the value of those colours however but this is just returning min value of the selected colour. 

Get_Cheapest_Colour =

 

var return_car = IF(ISFILTERED(Sheet1[Colour]),
values(Sheet1[Car]) ,BLANK() )

 

var get_all_colours = if( return_car <> BLANK(), VALUES(Sheet1[Colour]), BLANK())

 

var get_min_price = CALCULATE(
minx(Sheet1,Sheet1[Total Amount]),
Sheet1[Colour] = get_all_colours
)

 

return get_min_price

 

 data.PNGsample report.PNG

 

 
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can create a measure like

Cheapest colour =
var summaryTable = CALCULATETABLE( SUMMARIZE('Table', 'Table'[Car], 'Table'[Colour], 'Table'[Amount]), REMOVEFILTERS('Table'[Colour]))
var cheapestColours = TOPN(1, summaryTable, [Amount], ASC)
return CONCATENATEX( cheapestColours, [Colour], ", ")

The CONCATENATEX is in case there are multiple colours at the same price

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

You can create a measure like

Cheapest colour =
var summaryTable = CALCULATETABLE( SUMMARIZE('Table', 'Table'[Car], 'Table'[Colour], 'Table'[Amount]), REMOVEFILTERS('Table'[Colour]))
var cheapestColours = TOPN(1, summaryTable, [Amount], ASC)
return CONCATENATEX( cheapestColours, [Colour], ", ")

The CONCATENATEX is in case there are multiple colours at the same price

thanks @johnt75   that looks like its working as expected...now to apply to my actual complicated dataset!

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.