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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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