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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
coatsy35
Helper II
Helper II

Minus years from date in filter

All,

 

I am using the folowing measure, which works well. 

 

Measure  = CALCULATE(SUM('Dead Stock [Stk Value]),'Dead Stock'[Last Purchased Year]<=MAX('Dead Stock '[Last Purchased Year]))
 
However, I wish to have this filter only show items that are 5 years old or more i.e. 2019 or below. I have tried various things but unable to get it to work with years. If I type days like below in I get it to work, how can I alter it to allow years?
 
Measure  = CALCULATE(SUM('Dead Stock [Stk Value]),'Dead Stock'[Last Purchased Year]<=MAX('Dead Stock '[Last Purchased Year])-1825)
 
1 ACCEPTED SOLUTION
Gabry
Super User
Super User

Hello @coatsy35 

I suppose that [Last Purchased Year] actually is a full date column and not a year column. So if it's full date you can just write year('Dead Stock'[Last Purchased Year])<=year('Dead Stock'[Last Purchased Year])-4

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @coatsy35 ,

 

Based on your description, I created this data.

vkaiyuemsft_0-1725330432612.png


You think that Last Purchased Year is just YEAR probably because it is formatted as yyyy, when in fact the essence is still the full date column.

vkaiyuemsft_1-1725330464385.png


So you can try what Gabry  said and it will give you the correct results as well.

vkaiyuemsft_2-1725330489226.png


Alternatively, you could try creating a separate calculated column for year.

Year =
YEAR('Table'[Last Purchased Year])

 

Then, use the calculated column to get the desired result.

Measure 3 = 
CALCULATE(SUM('Table'[Stk Value]),'Table'[Year] <= MAX('Table'[Year]) - 5)

vkaiyuemsft_3-1725330530613.png

 

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Yuo are quite right. I wasn't looking correctly at the format. Sorted now with @Gabry answer. Thank you

Gabry
Super User
Super User

Hello @coatsy35 

I suppose that [Last Purchased Year] actually is a full date column and not a year column. So if it's full date you can just write year('Dead Stock'[Last Purchased Year])<=year('Dead Stock'[Last Purchased Year])-4

@Gabry its actaully a column of year and not date

So how can it works with -1825? Is it a number? Please provide sample data 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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