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

SAMEPERIODLASTYEAR not returning the correct data

I'm trying to do YOY sales information to see comparisons - like most people on here.  

 

First Formula:

Total Sales = Sum('Source Data'[Gross Revenue])

Second Formula : 

Total Sales LY = CALCULATE([Total Sales],SAMEPERIODLASTYEAR(Calender[Date].[Date]),ALLEXCEPT(Calender,Calender[Date].[Date]))

 

For the second formula, it's returning the sum of ALL the total sales, not breaking it out by month.  If I get rid of the ALLEXCEPT part, it shows the same information as "Total Sales".  How do I fix this?

1 ACCEPTED SOLUTION

@CheenuSing

This issue was stemming from the fact that PowerBI wasn't recognizing the date field as a true date field.  I had to create a new column that explicitly created a new date field for it to work.  Thanks.

View solution in original post

3 REPLIES 3
ngg4686
Frequent Visitor

I'm trying to follow these instructions here about three comments down :

https://community.powerbi.com/t5/Desktop/Comparing-this-year-and-last-year-measure-on-a-bar-chart/td...

@ngg4686

 

Few points you have to consider.

 

1. The Date table should have a key called DateKey of the format - (YYYYMMDD).

2. Similarly the FactTable should also have a key called FactDateKey of the format - (YYYYMMDD)

3. The two tables should be linked on the DateKey columns

4. The DateTable should be contigous and no gaps.

5. For the same period previous year it is enough to use the expression

   PYRSalesSamePeriod:=CALCULATE([Sales], SAMEPERIODLASTYEAR(Calendar[FullDate]))

  The Calendar here refers to the Calendar Table and the FullDate is a column in this table of format (DD/MM/YYYY).

  Replace it  with your names

 

Try it out and if this solves your problem please accept this as a solution and also give Kudos.

 

Cheers

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

@CheenuSing

This issue was stemming from the fact that PowerBI wasn't recognizing the date field as a true date field.  I had to create a new column that explicitly created a new date field for it to work.  Thanks.

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.