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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Sales Last year and Current Year

I need to calculate sales this year vs same period last year, but my problem is the way data is recorded. For 2021, sales are updated only once a month for previous month and all sales during that month have sales date as the first day of that month. For example, last month data is from February with all sales dates in that month being 2/1/2021. Same situation with sales recorded in 2020, basically we have 12 dates for entire year worth of sales (1/1/2020, 2/1/2020, 3/1/2020, and so on).

 

I tried using usual TOTALYTD and SAMEPERIODLASTYEAR but they keep giving me entire year worth of data for 2020 and up to date in 2021 since no other sales data is available past 02/2021 yet.

 

Any idea how I could solve this problem? One thing worth of mentioning is that I do not have date slicers since report is supposed to always show up to date information with same period last year for comparison.

1 ACCEPTED SOLUTION
themistoklis
Community Champion
Community Champion

@Anonymous 

 

Try the following formulas:

YTD = CALCULATE(SUM(Table[Amount]),DATESYTD('Calendar'[Date]))

YTD LY = CALCULATE([YTD],SAMEPERIODLASTYEAR('Calendar'[Date]))

 

YTD LY = CALCULATE ( [YTD], PREVIOUSYEAR ( Calendar[Date] ) )

View solution in original post

2 REPLIES 2
themistoklis
Community Champion
Community Champion

@Anonymous 

 

Try the following formulas:

YTD = CALCULATE(SUM(Table[Amount]),DATESYTD('Calendar'[Date]))

YTD LY = CALCULATE([YTD],SAMEPERIODLASTYEAR('Calendar'[Date]))

 

YTD LY = CALCULATE ( [YTD], PREVIOUSYEAR ( Calendar[Date] ) )

Anonymous
Not applicable

I tried these formulas but for some reason I get entire year worth of data, not January and February 2020 vs 2021 but entire 2020 vs whatever I have in 2021.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.