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

Help needed with SAMEPERIODLASTYEAR function

I need some help with SAMEPERIODLASTYEAR. I have a simple report that displays a date, Job Code Group, Count of terminations, and count of terminations for the same period of the prior year. The definitions of the termination measures is as follows:


     Terminations = SUM ( TERMS_fact_PSEmployee[Termed] )
     PriorYearTerms = CALCULATE(sum(agg_PSEmployee[Termed]),SAMEPERIODLASTYEAR(dim_Time[PeriodDate]))

 

This all seems to work as expected as shown below:

Date.PNG

I run in to problems when I try to display the data in a different time frame, such as fiscal year.  The totals show up fine, but the detail fro PriorYearTerms are missing:

 

Year.PNG

I assume this is caused by the use of SAMEPERIODLASTYEAR? Is there some sort of workaround for this?  What am I missing here?

 

A little background information, we are using direct query and the dates come from a time (date) dimension table. This is actaully a simplified version of the problem I am trying to solve. I didn't want to muddy the waters with more complex measures.

Thanks in advance for any assistance.

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @SGT,

 

Could you please post a sample in text mode? (pbix file will be better). 

1. Why are there two tables while you compare the same field? TERMS_fact_PSEmployee and agg_PSEmployee.

2. Are the "PeriodDate" and "FiscalYear" from the same table dim_Time?

3. What are the relationships?

 

Best Regards!

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Um, the detail is missing from the first image as well?

 

I would assume that what is going on is that there is some kind of context issue going on here. For some reason, putting FiscalYear into the table/matrix is causing your PeriodDate column to get filtered down to nothing or something that is not correct. You might be able to correct it by adding something like an ALL or ALLEXCEPT clause to your calculation but I'd have to see your data to really try to figure out what is going wrong.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.