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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Menvf
Frequent Visitor

Last 4 years + YTD

Hi,

 

I am trying to add a filter to my visuals in a report.

I want to see the last 4 years + YTD.

 

If I choose last 5 calendar years I don't get current year.

If I choose last 5 years I don't get the full last year, but rather a rolling 12 months period.

 

This was an attempt that I tried. Can't understand what goes wrong. I tried just creating an empty table and see which values get 1, and 2023 isn't getting any values to it. What am I doing wrong?

 

Is YTD or Last 4 Yrs =

VAR vToday = TODAY ()

VAR vYearOffset = 4

VAR vCurYear = YEAR ( vToday )

VAR vStartYear = vCurYear - vYearOffset

VAR vResult = IF (YEAR ( MAX ( 'Date Dimension'[Date] ) ) >= vStartYear && MAX ( 'Date Dimension'[Date] ) <= vToday;

1;

0)

RETURN vResult

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Menvf ,Try a measure like

 

YTD Today +4 =
var _min = date(year(today()) -4,1,1)
var _max = today()
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max)) // assuming you are using date table or use date from table

@amitchandak thank you for your effort, however it still doesn't work even when I change the date reference.
What is the [Net] reference in the calculate?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.