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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

DAX Measure for Max Value Based on Year

Hi,

I have a data set that has values and the year that value was recorded. I want to create a measure that will display the maximum value for that year when I add it to a table. For example, my data looks like this:

YearValue
20081
20083
20081
20094
20103
20105
20101
20113
20112
20121

 

So the measure I want would add a column to the table that looks like this:

YearValueMax
200813
200833
200813
200944
201035
201055
201015
201133
201123
201211

 

I tried:

Measure = CALCULATE(MAX('Table'[Value]))
but it just returns the number in the Value column.
I also need to do the same for Min, but I figure that will be the same DAX just with MIN instead of MAX.
 
Thanks
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,

try like

Measure = CALCULATE(MAX('Table'[Value]),allexcept('Table'[Year]))

View solution in original post

4 REPLIES 4
neha369
Helper I
Helper I

You can also try 

 

Column = CALCULATE(MAX('Table'[Value]),GROUPBY('Table','Table'[Value]))
 
 
 
amitchandak
Super User
Super User

@Anonymous ,

try like

Measure = CALCULATE(MAX('Table'[Value]),allexcept('Table'[Year]))

Anonymous
Not applicable

Thank you, that works.

What if I want the average for each year?

YearValueAverage
20081

1.66

200831.66
200811.66
200944
201033
201053
201013
201132.5
201122.5
201211

 

 

HI @Anonymous,

You can try below measure formula if it works:

Measure =
CALCULATE (
    AVERAGE ( table[Value] ),
    ALLSELECTED ( table ),
    VALUES ( table[Year] )
)

You can change the aggregate functions to apply different summary mode on your fields. (min, max, sum, average...)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.