cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
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] ) )

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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors