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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
dats
Resolver I
Resolver I

Week inclusion in SamePeriodLastyear

Hi all,

 

I have an issue with the 'Sameperiodlastyear' DAX formular. my initial data table looks something like this:

 

DateStart of the weekYearweeksales
19.05.201914.05.20192019201
20.05.201920.05.20192019212
...............

 

It has all the week from 01.01.2018 (week one of 2018)  to 17.05.2020 (week 2020)

 

Furthermore, from the same table I retriev the total sum of sales. Now I would like to create a table that looks like this:

 

YearTotal SalesSamePeriodlastyear
2018500 
20191000500
20202001000

 

But what I receive is this:

 

YearTotal SalesSamePeriodlastyear
2018500500
20191000300
2020200 

 

The 300 and 500 are the issues here. For 2020 my data inlcudes sales including week 20. So I would expect the same period last year function to also show just the first 20 weeks. But for some reason it includes 22 weeks.

 

My Formulars are Total= SUMX(Category,Category[Value])and CALCULATE( [total]; SAMEPERIODLASTYEAR(Date;Date[StartofWeek])

 

Ho das powerbi figures out the

what could be the issue tah powerbi includes 22 weeks for 2019 rather than 20 and ho can i display the number for 2019 in 2020 ,..

 

greeting

 

 

 

 

1 ACCEPTED SOLUTION

@Greg_Deckler Thanks for the tip. I will try it later on.

 

I found another way that works as well.

 

weeklysales = calculate([ValueTotalCategory];Filter(ALL('Date');'Date'[CalendarYear]=SELECTEDVALUE('Date'[CalendarYear])-1 && 'Date'[Week]=SELECTEDVALUE('Date'[Week])))

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@dats - See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks for the tip. I will try it later on.

 

I found another way that works as well.

 

weeklysales = calculate([ValueTotalCategory];Filter(ALL('Date');'Date'[CalendarYear]=SELECTEDVALUE('Date'[CalendarYear])-1 && 'Date'[Week]=SELECTEDVALUE('Date'[Week])))

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors