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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
qmestu
Helper III
Helper III

Min and Max not working

Hi,

I have the following table (an example)

Year Value Category
2020 5 A
2019 3 A
2018 2 A
2020 8 B
2019 4 B
2020 2 C


How can i create a measure that returns the Value for the earliest year, for each category.

I tried the following:

Value (earliest) =
var firstYear=minx('table','table'[Year])
return CALCULATE(sum(Value),'table'[Category]="A",'table'[Year]=firstYear)

But it doesn't work. It seems that min, minx or maxx always return the highest value.

Thanks for any help.

1 ACCEPTED SOLUTION

I just re-read your post and missed that you actually wanted the value! Try this

Value first year = 
var firstyear = CALCULATE(MIN('Table'[Year]),ALLEXCEPT('Table','Table'[Category]))
return CALCULATE(sum('Table'[Value]),'Table'[Year]=firstyear)

Syk_0-1654186646289.png

 

View solution in original post

6 REPLIES 6
ribisht17
Super User
Super User

Step 1

Latest Year=calculate(max(year),ALLEXEPT(TABLE,CATEGORY))

 

Step2

Latest Value=IF(max(Year)=Latest Year,sum(value),0)

 

Filter out 0

 

Regards,

Ritesh

The first step returns the same value wether i use min or max.

Syk
Super User
Super User

try something like this... 

First year = MINX(SUMMARIZE('Table','Table'[Category]),'Table'[Year])

 

Error message that a single value for year cannot be determined.

I just re-read your post and missed that you actually wanted the value! Try this

Value first year = 
var firstyear = CALCULATE(MIN('Table'[Year]),ALLEXCEPT('Table','Table'[Category]))
return CALCULATE(sum('Table'[Value]),'Table'[Year]=firstyear)

Syk_0-1654186646289.png

 

Hi @qmestu ,

Please try this : 

rohit_singh_0-1654185976909.png

Earliest value =

var _category = SELECTEDVALUE(MinYear[Category])

var _minyear =
CALCULATE(
MIN(MinYear[Year]),
FILTER(
ALLSELECTED(MinYear),
MinYear[Category] = _category
)
)

var _minval =
CALCULATE(
MIN(MinYear[Value]),
FILTER(
ALLSELECTED(MinYear),
MinYear[Category] = _category && MinYear[Year] = _minyear
)
)

RETURN
_minval

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors