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 August 31st. Request your voucher.

Reply
Karenh
New Member

How setup a last year with the same month to the current year

Hi Community 

 

I need to compare the current year versus the last year, but my current year has only information from (Jan23 to Jul-23) qnd with this if I try to compare with the last year that hsa 12 months (Jan22 to Dec22) the comparission is wrong. so, Any idea how can I filter the last year according the period that I have in current year?

5 REPLIES 5
vanessafvg
Super User
Super User

please provide some sample data in text form with an example of your expected result.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Thanks, find enclosed the file with the example. 

Karenh_0-1698438442842.png

 

sorry I need text data, can you copy and paste it in

 

my internet was hanging and pushed accept as solution, apologies will try to remove it but can you please copy and past the text?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




here you go 

DATA 2022                      DATA 2023
Jan-22 1,000.00              Jan-23  5,000.00
Feb-22 2,000.00             Feb-23  3,500.00
Mar-22 1,000.00             Mar-23  1,000.00
Apr-22 2,000.00              Apr-23  5,000.00
May-22 1,000.00            May-23  3,500.00
Jun-22 1,400.00               Jun-23  1,000.00
Jul-22 1,400.00
Aug-22 1,400.00
Sep-22 1,400.00
Oct-22 1,400.00
Nov-22 1,400.00
Dec-22 1,400.00
Total 16,800.00                  19,000.00

 

URRENT RESULT
LAST YEAR       CURRENT YEAR
 16,800.00        19,000.00
 
EXPECTED RESULT
LAST YEAR CURRENT YEAR
 8,400.00            19,000.00 COMPARE THE SAME MONTHS FROM JAN TO JUN
 
Thanks

I used this example from SQLBI

https://www.sqlbi.com/articles/previous-year-up-to-a-certain-date/

 

You need to create a flag to assess when there is a value from the current year for previous year and then use that in your measure, and then it will only show you when have a value in both years.  

 

IsPast =
VAR CurrDate = MAX ( data[Date])
VAR LastSDatePY = EDATE ( CurrDate, -12 )
RETURN
    'Date'[Date] <= LastSDatePY
 
Previous Year =
CALCULATE (
    [total amount],
    SAMEPERIODLASTYEAR ( 'Date'[Date] ),
    'Date'[IsPast] = TRUE
)

 

 

vanessafvg_0-1698603509689.png

 

see file attached.  

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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