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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How to return same period last year when period is self-defined?

My data set looks like the following. Each year is divided into multiple pricing windows, and the start date of each pricing window falls on a different date each year. How do I create a measure so I can have volume for current year pricing window and that for last year same pricing window side by side?

 

I tried the below, but it is returning the sum of all volumes in that pricing window, instead of by SKU.

Last Pricing Window = calculate(sum('Pricing window table'[Volume]), filter(ALL('Pricing window table'), 'Pricing window table'[Year] = max('Pricing window table'[Year])-1 && 'Pricing window table'[Pricing Window] = max('Pricing window table'[Pricing Window])))

 

SKUYearPricing WindowVolumePriceDate
SKU 120201200451/2/2020
SKU 120202210462/1/2020
SKU 120203189453/4/2020
SKU 120204120454/1/2020
SKU 220201300451/2/2020
SKU 220202250462/1/2020
SKU 220203204433/4/2020
SKU 220204350454/1/2020
SKU 120191120441/1/2019
SKU 120192126442/1/2019
SKU 120193200433/1/2019
SKU 12019472434/1/2019
SKU 220191360441/1/2019
SKU 220192300422/1/2019
SKU 220193200433/1/2019
SKU 220194420444/1/2019
1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this measure:

 

_LY =
VAR _year = SELECTEDVALUE('Table'[Year])
RETURN
CALCULATE(SUM('Table'[Volume]);
FILTER(ALLEXCEPT('Table'; 'Table'[SKU]; 'Table'[Pricing Window]); 'Table'[Year] = _year - 1))
 

If you consider it as a solution, please mark as a solution and kudos.

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

1 REPLY 1
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this measure:

 

_LY =
VAR _year = SELECTEDVALUE('Table'[Year])
RETURN
CALCULATE(SUM('Table'[Volume]);
FILTER(ALLEXCEPT('Table'; 'Table'[SKU]; 'Table'[Pricing Window]); 'Table'[Year] = _year - 1))
 

If you consider it as a solution, please mark as a solution and kudos.

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
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 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.