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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

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