Forum Discussion
derekmalag
4 years agoNew Member
Calculated Colum: Get MIN value from a filtered table
Hi, I'm stuck in something that I think it is simple but I can't make it work so I'm pretty sure I'm doing something incorrectly but don;t know what so would appreciatte any light on it. I have a...
- 4 years ago
derekmalag Here are a couple different ways:
MIN_VALUE = CALCULATE ( MIN('MyTable'[Total_Value]), FILTER('MyTable',[Model]=EARLIER('MyTable'[Model])) ) MIN_VALUE = VAR __Model = [Model] RETURN CALCULATE ( MIN('MyTable'[Total_Value]), FILTER('MyTable',[Model]=__Model) )
Greg_Deckler
4 years agoCommunity Champion
derekmalag Here are a couple different ways:
MIN_VALUE =
CALCULATE (
MIN('MyTable'[Total_Value]),
FILTER('MyTable',[Model]=EARLIER('MyTable'[Model]))
)
MIN_VALUE =
VAR __Model = [Model]
RETURN
CALCULATE (
MIN('MyTable'[Total_Value]),
FILTER('MyTable',[Model]=__Model)
)
- derekmalag4 years agoNew Member
amazing Greg_Deckler , I've used the [EARLIER] option and it works so not going through the second :). Assuming not, but just to be sure, if there is any consideration in performance between these two options?
Many thanks again
- Greg_Deckler4 years agoCommunity Champion
derekmalag In my testing, no I have not seen a performance difference between the two approaches. You might be interested in this: In Defense of EARLIER - Microsoft Power BI Community
- AlexisOlson4 years agoSuper User
derekmalag If you're concerned about performance, then you should filter on columns rather than tables whenever possible.
I'd probably write it like this instead:
MIN_VALUE = CALCULATE ( MIN ( 'MyTable'[Total_Value] ), ALLEXCEPT ( 'MyTable', 'MyTable'[Model] ) )