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
zivhimmel
Resolver I
Resolver I

SAMEPERIODLASTYEAR weird behavior when including today

Hi,

I have used SAMEPERIODLASTYEAR to create a measure showing me values of the previous year.

 

Guests = DISTINCTCOUNT('Fact Guest Enquiry'[enquiry_id])

Guests Previous Year = CALCULATE(Guests,SAMEPERIODLASTYEAR('Dim Date'[Date]))

 

There's a relationship between 'Fact Guest Enquiry' and Dim Date (fact.enquiry date and dim.date).

In my report I have a date filter. Users can choose a range and I display both the guests for the range chosen, and the figure for the same period last year, using the measure shown above.

 

This works very well, except for one case, which is when today is included (either by choosing a specific date range which includes today, or by using a relative filter and chosing to include today). When today is included, the figures for this year are correct, but for same period last year, they jump up by a few hundreds.

I verified and these few hundreds are not legit - there aren't such records in the previous year.

 

Any ideas? Thanks.

3 REPLIES 3
Anonymous
Not applicable

Hi @zivhimmel,

I'd like to suggest you use date function to manually defined the calculation ranges, it is more agility than time intelligence functions and not required a complete calendar table.

Time Intelligence "The Hard Way" (TITHW)  

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@zivhimmel , Make sure your date/calendar table is marked as date table. This should work with today too.

 

Try this type of formula

Year behind = CALCULATE([Guest]),dateadd('Dim Date'[Date],-1,Year))

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak . I tried your suggestions. Marked the table as a date table and tried your DAX formula.

Unfortunately it returns the same result.

 

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.