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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

Error when display value for maximum year but the value shows other year too

Hello experts,

 

I want to display the value for maximum year.

For example, the maximum year will be the latest year which is 2022, so the values should only display data for year 2022. But there are few values from year 2020 also have been displayed which is not correct.

My formula looks like below.. Need your help & insights on this..

 

var latestYear = YEAR(MAX('table'[date]))
var valueX =CALCULATE(SUM('table'[Value])/1000, table[category]"pink"
YEAR('table'[date])=latestYear)
return
valueX
 
 
Thanks in advance.
Izzaty
2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

You can try this code to create a measure.

Value in Max Year =
VAR _latestYear =
    YEAR ( MAXX ( ALL ( 'table' ), 'table'[date] ) )
VAR _valueX =
    CALCULATE (
        SUM ( 'table'[Value] ) / 1000,
        FILTER (
            'table',
            AND ( table[category] = "pink", YEAR ( 'table'[date] ) = _latestYear )
        )
    )
RETURN
    _valueX

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Try a measure like (With help from a separate date table

 

var latestYear = YEAR(MAX('table'[date]))

CALCULATE(SUM('table'[Value])/1000, table[category]= "pink",
filter(all('Date') , YEAR('Date'[date])=latestYear) )

 

 

refer

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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