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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
derekmalag
New 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 Table with two columns and I want to create a calculated column that get the Min value of the Model. The expected output is 

ModelTotal_ValueMIN_VALUE
A3 *3
A43
B52
B2*2
C97
A63
C7*7
B82

 

So I've tried the following DAX query for the calculated column

 

MIN_VALUE = CALCULATE (
     MIN('MyTable'[Total_Value]),
     FILTER('MyTable',[Model]=[Model])
)

 

 However, what I get is the minimum value of the table without being filtered (2 for all values).

 

I would appreciate any help on what I am doing wrong.

 

Many thanks in advance

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community 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)
  )



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Here is the simple one line solution:

shwetadalal_0-1638614475944.png

Min_Value = CALCULATE(MIN('Table'[Total Value]),FILTER('Table',EARLIER('Table'[Model])='Table'[Model]))
HotChilli
Super User
Super User

@Greg_Deckler did I just catch you using a "CALCULATE"? 

 

can't we rely on anything any more?....

@HotChilli Ha! Good one. I was actually going to include a version using MINX but figured it was overkill. Was easier just to correct the version of the formula that used CALCULATE since it was already there.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community 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)
  )



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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 

@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] )
)

@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



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.