cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ngg4686 Frequent Visitor
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

Accepted Solutions
ngg4686 Frequent Visitor
Frequent Visitor

Re: SAMEPERIODLASTYEAR not returning the correct data

@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.

3 REPLIES 3
ngg4686 Frequent Visitor
Frequent Visitor

Re: SAMEPERIODLASTYEAR not returning the correct data

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...

Super User
Super User

Re: SAMEPERIODLASTYEAR not returning the correct data

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

Re: SAMEPERIODLASTYEAR not returning the correct data

@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.