Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
LyncoData1
Helper I
Helper I

PYTD

Hello, 

 

I am having trouble with pulling Net Sales for the month of March. I am trying to compare current year sales to prior year sales and drill down. I am comparing Net Sales for the full year of 2019 to 2020. Everything is pulling correct besides the month of March. Today is 3/19/2020 and my prior year for the month of March continues to pull the entire month from 3/1/2019 to 3/31/2019 when I only want it to pull from 3/1/2019 to 3/18/2020. I would like my numbers to reflect the same time period for this March 2020 but it keeps pulling the entire month of March 2019. I am not sure how to manipulate my measure so it will only pull sales up to the 18th in the month of March in 2019. I have my measures listed below. Any help will be greatly appreciated.

 

My Data 

2020 March Net Sales = 400

2019 March Net Sales = 1,200   // My March 2019 Net Sales should be lower than 1,200

 

My Net Sales Measure: 

NetSales = CALCULATE(SUM(FactNetSales[Amount]))
 
Measure to pull prior year sales:
PYTDSales =
CALCULATE(
[NetSales],
SAMEPERIODLASTYEAR(
'DimCalendar'[DateKey]
)
)
 
1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @LyncoData1

 

I‘ve tested your measure with my sample data and it works fine.You need to use the dimCalendar [date]  as the slicer,then you will see:

Annotation 2020-03-20 144230.pngAnnotation 2020-03-20 144339.png

 

Do remember to create a relationship between FactNetSales table and DimCalendar table.

 

Here is my .pbix file.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
 

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @LyncoData1

 

I‘ve tested your measure with my sample data and it works fine.You need to use the dimCalendar [date]  as the slicer,then you will see:

Annotation 2020-03-20 144230.pngAnnotation 2020-03-20 144339.png

 

Do remember to create a relationship between FactNetSales table and DimCalendar table.

 

Here is my .pbix file.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
 

Thank you so much! This worked. However, the month of Feb in 2020 has duplicated the same values from Feb 28th to Feb 29th (159.20). I am not sure if it is because the month of Feb is a day longer compared to previous years where Feb is typically 28 days. When I only bring in Net Sales for 2019 the number does not duplicate. However, when I use PYTDSales measure the numbers duplicate themselves. Do you have any insight on how to fix?  

 

PBI.JPG

 
 
 
Greg_Deckler
Community Champion
Community Champion

When using time intelligence functions you generally need a separate date table. 

 

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.