cancel
Showing results 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

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

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

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

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

Top Solution Authors
Top Kudoed Authors