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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
AnthonyJoseph
Resolver III
Resolver III

check if item exists in the latest year

Hello,

 

I have a table visual and would like to display if the item that exists in the latest year (latest year in the data selected) by a measure.

 

Below is the sample data and expected output:

Unit table:  
ItemYearunit
Fruit2022100
Fruit2021200
Fruit2020500
Veggies2021100
Veggies202040
Meat2022150
Meat2021250

 

Expected output:  Here "Item exist in the latest selected year" is the output measure that will say whether the Item exists in the latest year (here 2022 is the latest or maximum year). If the item exists in the latest year then it should return "Yes" else if the item is not there in the latest year then it should be "No".

 

ItemYearunitItem exist in the latest selected year
Fruit2022100Yes
Fruit2021200Yes
Fruit2020500Yes
Veggies2021100No
Veggies202040No
Meat2022150Yes
Meat2021250Yes

 

Please can you let me know how to achieve this result.

 

Thanks,

AnthonyJoseph

1 REPLY 1
vicky_
Super User
Super User

Hello!
Try something like:

Exist in latest year = 
var latest = CALCULATE(MAX('Table'[Year]), ALLSELECTED('Table'))
var itemsInLatestYear = SELECTCOLUMNS(FILTER(ALL('Table'), 'Table'[Year] = latest), "Items", 'Table'[Item])
return IF(SELECTEDVALUE('Table'[Item]) in itemsInLatestYear, "Yes", "No")

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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