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
r_ramillien
Regular Visitor

Filing a column with the min value of another column

Hello all,

 

I stuck on a problem which seems very basic.

 

I would like to create a column or measure which contains the minimum value of all rows of another column.

I want to it to be sensitive to filters, that's why I can't use power query.

 

To make an example, I have a table like this.

 

key | value

0    | 10

0    | 20

0    | 30

1    | 5

 

Supposing I have a filter on key 0, I would have someting like this:

 

key | value | min

0    | 10      | 10

0    | 20      | 10

0    | 30      | 10

 

This is not my "real" use case. But I need this step to implement it.

I tried a lot of solutions based on min, mina, minx, etc. Using columns or measures, but nothing seems to work. In most cases, the min value is equal to the value of the same row. So, how can I do to fill all the rows with the min value found in filtered rows ?

 

I think I approches a solution with this kind of formula:

CALCULATE(MIN('Test'[value]), ALLEXCEPT('Test', 'Test'[key], 'Test'[another column]))

But if I remove the "allexcept", this do not works anymore. I would not add all my segments in the allexcept. I would like CALCULATE to use the segments on the page.
 

Best regards,

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

To have it respond to slicers, it needs to be a measure.  Please try this one.

 

MinThisKey = CALCULATE(MIN(test[value]), ALL(test[Value]))

mahoneypat_0-1634430326646.png

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Employee
Employee

To have it respond to slicers, it needs to be a measure.  Please try this one.

 

MinThisKey = CALCULATE(MIN(test[value]), ALL(test[Value]))

mahoneypat_0-1634430326646.png

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hello,

 

Thank you, it works great !


When I read the documentation for "ALL", I understand that it resets all filters. So I thought the result for all rows would have been "5" instead of 10. I'm not sure to understand how it works then, but it works. Thank you !

CNENFRNL
Community Champion
Community Champion

Resort to Calculated Column since it's only an intermediate step.

Screenshot 2021-10-16 222653.png


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!

Hello,

 

Thank you for your help, I see that it works for you. But the same code do not works for me !?

 

Capture d’écran 2021-10-16 232017.png

 

It says "EARLIER/EARLIEST make a reference to a previous row context which do no exists."

 

Any idea please ?

 

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.

Top Solution Authors