Forum Discussion
Identify max value in a column
I would like to create a custom column that returns the text " Latest Year" in any row where the year contains the max value.
| Status | Year |
| Budget | 2024 |
| Budget | 2023 |
| Budget | 2022 |
| Budget | 2021 |
The end result would be below
| Status | Year | New Column |
| Budget | 2024 | Latest Year |
| Budget | 2023 | |
| Budget | 2022 | |
| Budget | 2021 |
Anonymous
Yes you can:IF ( Tablename[Year] = CALCULATE( MAX( Tablename[Year] ), ALLEXCEPT( Tablename, Tablename[Status] ) ), "Latest Year" )
6 Replies
- FowmySuper User
Anonymous
Try this calculated column:New Collumn = IF ( tablename[year] = MAX( tablename[year] ) , "Latest Year")- AnonymousNot applicable
Fowmy thank you this is a good start for me. I actually have two categores that i need to calculate the latest year for within the same column. One is budget and the other is forecast. Is there a way to place the " Latest Year" identifier for each category. see the example below.
Status Year New Column Budget 2024 Latest Year Budget 2023 Budget 2022 Budget 2021 Forecast 2311 Latest Year Forecast 2308 Forecast 2306 I was originally going to use a custom column in query editor to identify the latest year for each category (Budget and forecast) and then I would have appended the columns together.
- FowmySuper User
Anonymous
Yes you can:IF ( Tablename[Year] = CALCULATE( MAX( Tablename[Year] ), ALLEXCEPT( Tablename, Tablename[Status] ) ), "Latest Year" )
- Dangar332Resident Rockstar
HI, Anonymous
Anonymous
try below code for new columnjust adjust your table name
Column = var a= 'Table (2)'[status] var b = MAXX(FILTER('Table (2)','Table (2)'[status]=a),'Table (2)'[year]) return IF('Table (2)'[year]=b,"latest year",BLANK())Table (2)'[status]=a),'Table (2)'[year])