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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
srb803
Frequent Visitor

Same month Last Year Calculation without Date Column

I have sample data below.  I have the first 3 columns in data and need the fourth column as Output using some measure.
This is a SAMEPERIODLASTYEAR calculation. But I don't have a data table here and need to perform the same without that.
There is a gap of 52 in TimePeriod ID for the current year to the previous year. In front of Year Period 2023 P01 I want to display the value of 2022 P01. Any help on this is highly appreciated.

TimePeriod IdYear PeriodSalesOutput
7202022 P01205,665,639 
7212022 P02/Jan (P01 UK)562,029,814 
7222022 P03/Feb (P02 UK)527,383,577 
7232022 P04/Mar (P03 UK)565,887,301 
7242022 P05/Apr (P04 UK)542,678,959 
7252022 P06/May (P05 UK)562,461,640 
7262022 P07/Jun (P06 UK)578,394,711 
7272022 P08/Jul (P07 UK)589,874,511 
7282022 P09/Aug (P08 UK)595,922,630 
7292022 P10/Sep (P09 UK)571,743,337 
7302022 P11/Oct (P10 UK)586,392,877 
7312022 P12/Nov (P11 UK)565,781,614 
7322022 P13/Dec (P12 UK)614,625,239 
7722023 P01212,356,814205,665,639
7732023 P02/Jan (P01 UK)575,469,178562,029,814
7742023 P03/Feb (P02 UK)536,807,617527,383,577
7752023 P04/Mar (P03 UK)567,604,233565,887,301
7762023 P05/Apr (P04 UK)551,113,048542,678,959
7772023 P06/May (P05 UK)569,717,273562,461,640
7782023 P07/Jun (P06 UK)570,487,557578,394,711
7792023 P08/Jul (P07 UK)588,423,582589,874,511
7802023 P09/Aug (P08 UK)589,004,529595,922,630
7812023 P10/Sep (P09 UK)558,480,144571,743,337
7822023 P11/Oct (P10 UK)569,575,618586,392,877
7832023 P12/Nov (P11 UK)563,250,912565,781,614
7842023 P13/Dec (P12 UK)528,280,049614,625,239
1 ACCEPTED SOLUTION
speedramps
Super User
Super User

All reports use dates, so it is really important that you always use standard dates.

Never use bespoke dates like 

2022 P03/Feb (P02 UK)

 

Always use Power Query to convert them to a standard date like 01/02/2022.

Then you can use standard YOY comparions and testing.

Learn how here https://www.youtube.com/watch?v=CJ2y6v4mQZk 

 

You can use Power query to convert the date like this

= Table.AddColumn(Source, "Date", each Date.FromText(
Text.Start([Year Period], 4) &
Text.Middle([Year Period], 6, 2) &
"01" ))

 

You will have to tweak my example to convert P13 to December

but this shows you how easy it is to use Power Query to convert besoke dates like

2022 P03/Feb (P02 UK)

to a standard dates

speedramps_1-1706807664789.png

 

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

View solution in original post

1 REPLY 1
speedramps
Super User
Super User

All reports use dates, so it is really important that you always use standard dates.

Never use bespoke dates like 

2022 P03/Feb (P02 UK)

 

Always use Power Query to convert them to a standard date like 01/02/2022.

Then you can use standard YOY comparions and testing.

Learn how here https://www.youtube.com/watch?v=CJ2y6v4mQZk 

 

You can use Power query to convert the date like this

= Table.AddColumn(Source, "Date", each Date.FromText(
Text.Start([Year Period], 4) &
Text.Middle([Year Period], 6, 2) &
"01" ))

 

You will have to tweak my example to convert P13 to December

but this shows you how easy it is to use Power Query to convert besoke dates like

2022 P03/Feb (P02 UK)

to a standard dates

speedramps_1-1706807664789.png

 

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.