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

SAME PERIOD LAST YEAR not working properly in tables

I have a table that compares current year sales to prior year sales.    My data at the back is a simple two column data: Date and Sales

 

At the front I used the sameperiodlastyear function to creat a measure:

PY Sales = calculate([Total sales],SAMEPERIODLASTYEAR(Sheet1[Date]))

 

  But the table does not display it properly, there is a total below but each month is blank.  Any thoughts?

 

Much appreciate anyone who can help.  

 

Capture1.JPG

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @casterchen,

Based on my test, you need to create a calender table firstly and create the one-to-one relationship:

New table:

Table = CALENDARAUTO()

Relationship:

1.PNG

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

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

View solution in original post

4 REPLIES 4
v-danhe-msft
Employee
Employee

Hi @casterchen,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-danhe-msft
Employee
Employee

Hi @casterchen,

Based on my test, you need to create a calender table firstly and create the one-to-one relationship:

New table:

Table = CALENDARAUTO()

Relationship:

1.PNG

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
venug20
Resolver I
Resolver I

@casterchen

 

Use this one...

 

YTD = calculate([Total sales], DATESYTD(Sheet1[Date].Date))

 

PY Sales = calculate([YTD],SAMEPERIODLASTYEAR(Sheet1[Date].Date))

 

If it is solution for your query, Pls accept as solution... it is helpful to others....

Thanks venug20, but wouldn't this give me YTD value rather than just the monthly value?

 

I'm travelling and don't have access to the dataset.  Will give it a try once I can get my hands onto it. 

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.