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

View all the Fabric Data Days sessions on demand. View schedule

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
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