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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
BlizG
New Member

YTD - YTD Last year

Hello.
I have an issue regarding YTD - YTD last year.

Currently I am using 

TOTALYTD and it works fine for this year, for next measure for last year using SAMEPERIODLASTYEAR counts the whole year which is not what i want. 
The issue is that I am only interested in to compare the the same period meaning 2023-01-06 to 2022-01-06.

I am thinking of creating a VAR lastyear as = date(year(today()) -1, ) or something similar to use it as a filter. 
I am using a matrix for the visualisation, and i will have different measurements comparing the same YTD - YTD last year, so having a filter on a visual will not work for me. 

 

Any suggestions are welcome

1 ACCEPTED SOLUTION
BlizG
New Member

What I did to solve this issue:

Created a column:

Var maxdate =max(table[datecolumn])

Datediff(table[datecolumn]),maxdate,day)

 

Made a new measure:

Calculate(countx(table,table[column]), filter1,filter2,filter3,and last filter was the new created colmn>=365.

My data imported only is from 2022 onwards, if i had multilple years i just add another filter with <=730.

View solution in original post

2 REPLIES 2
BlizG
New Member

What I did to solve this issue:

Created a column:

Var maxdate =max(table[datecolumn])

Datediff(table[datecolumn]),maxdate,day)

 

Made a new measure:

Calculate(countx(table,table[column]), filter1,filter2,filter3,and last filter was the new created colmn>=365.

My data imported only is from 2022 onwards, if i had multilple years i just add another filter with <=730.

AliceW
Power Participant
Power Participant

A quick way of doing this is having two filters for the Date. Power BI doesn't have one which does this, so using one twice solves the problem.

AliceW_0-1672991291372.png

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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