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
Anonymous
Not applicable

Return min value

Hi there, I have a question on return min value. Below is a sample data set. 

dmkblesser_1-1601011170605.png

Under Company column, the last two rows are blank. 

 

I would like to have a measure to return the company name with a minimum price. However, when Company name = null, the corresponding price value should not be included. In this case, 0 would not be considered. 

 

Also, price can be duplicate. So I'd like to return either the first company value or the last company value unless there is a better way to handle this. 

 

Here is my measure but doesn't work:

MINSUB =
VAR min_pice =
CALCULATE(MIN(Table[PRICE]),(Table[Company] <> ""))
VAR min_sub =
FIRSTNONBLANK(TABLE[COMPANY],FILTER(Table,price = min_pice))
return min_sub
 
Any help will be much appreciated 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like

 

MINSUB =
VAR min_pice =CALCULATE(MIN(Table[PRICE]),filter(Table, Table[Company] <> "" && not(isblank(Table[Company]))))

VAR min_sub =
calculate(min(TABLE[COMPANY]),FILTER(Table,price = min_pice && Table[Company] <> "" && not(isblank(Table[Company]))))
return min_sub

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try like

 

MINSUB =
VAR min_pice =CALCULATE(MIN(Table[PRICE]),filter(Table, Table[Company] <> "" && not(isblank(Table[Company]))))

VAR min_sub =
calculate(min(TABLE[COMPANY]),FILTER(Table,price = min_pice && Table[Company] <> "" && not(isblank(Table[Company]))))
return min_sub

Anonymous
Not applicable

Thank you so much. It worked!

 

I'm just trying to understand it. Because it is a measure, so that it will return an aggregated value, and that's why we can use min on a text column?

 

also, what's the meaning of  not(isblank(Table[Company]) for both variable? I thought  Table[Company] <> ""  handles the blank fields but seems it does not? 

 

Again thank you very much for your quick answer. @amitchandak 

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.