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
TradSag
Frequent Visitor

SAMEPERIODLASTYEAR not showing all records

Hi Team,
 
I have found a not expected behaviour using SAMEPERIODLASTYEAR function.
 
Context:
 
  • Account table containing fields: Date, Account, Account_Group and Amount fields.
  • Calendar table generated based on Account table Date field. This table is marked as Date table and linked to Account table.

image.png

 
I'm trying to compare the vaule from currently selected date versus previous year same value. For this I'm using SAMEPERIODLASTYEAR function in the following way: 
 
PY_Amount = CALCULATE(Sum('Account'[Amount]);SAMEPERIODLASTYEAR('Calendar'[Date]))
 
Issue:
 
As an example, selecting May 2019, this is the result:
 
image.png
If we check May data separatelly by year 2018 and 2019, we find the following:
 
image.pngimage.png
 
As you can check in the initial image (the one that shows Amount and PY_Amount), we don't find the record corresponding to account 88170000000 marked with a red box in 2018 image.
 
I assume that the record is not shown because we it does not exist in 2019 context, but how can we avoid this behaviour?
 
Thanks for the support,
 
Best regards
 
Best regards
1 ACCEPTED SOLUTION
TradSag
Frequent Visitor

Hi,

 

I have solved the issue.

 

I removed the configuration that makes Calendar table into Date table and use the formula as following:

 

PY_Amount = CALCULATE(Sum('Account'[Amount]);SAMEPERIODLASTYEAR('Calendar'[Date].[Date]))
 
Adding .[Date] option makes the issue to be resolved.
 
Thanks and regards

View solution in original post

3 REPLIES 3
TradSag
Frequent Visitor

Hi,

 

I have solved the issue.

 

I removed the configuration that makes Calendar table into Date table and use the formula as following:

 

PY_Amount = CALCULATE(Sum('Account'[Amount]);SAMEPERIODLASTYEAR('Calendar'[Date].[Date]))
 
Adding .[Date] option makes the issue to be resolved.
 
Thanks and regards
vanessafvg
Super User
Super User

try putting an all in

 

test =
CALCULATE (
    SUM ( 'Account'[Amount] ),
    ALL ( 'Calendar'[Date] ),
    SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi,

 

Thanks for the answer.

 

Unfortunately, this is not working. I'm getting same the exactly the same result.

 

Any ideas?

 

Thanks and regards

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.