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
Rate
Helper III
Helper III

Help with 2018 and 2019 comparison (with different months)

Hello!!

 

I have a project that started on July 2018, with daily data for sales. We would want to include a comarison with the sales for 2018 (July to December 2018) against the sales form 2019 (January up to today).

 

For 2019 data I am using the Quick Measure for Total Year To Date and everyhing works great.

However, I am struggling enormously with the formula for the data for 2018. I have tried the following:

1. Of course, if I include a hard coded 2018 as a condition in the Calculate, the filters don't work.

2. I have tried with SAMEPERIODLASTYEAR, as everyone recommends, but in my case, as I don't have data for a full year, is not viable.

3. I tried DATEADD from my Dates table, but I only get blanks.

    DATEADD(
        Date.[Date], -1, YEAR))

Do you have any suggestions on another method that I could use?

 

Thanks a lot and kid regards!!

 

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Rate ,

As suggested, you could create a calendar table with CALENDARAUTO() and then you could create the measure like below.

2019 = TOTALYTD(SUM('Data'[Sales]),'Table'[Date])
2018 = var a =DATEADD('Table'[Date],-1,YEAR) return TOTALYTD(SUM('Data'[Sales]),a)

Here is the output.

Capture.PNG

You also could refer to my attachement.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
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-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Rate ,

As suggested, you could create a calendar table with CALENDARAUTO() and then you could create the measure like below.

2019 = TOTALYTD(SUM('Data'[Sales]),'Table'[Date])
2018 = var a =DATEADD('Table'[Date],-1,YEAR) return TOTALYTD(SUM('Data'[Sales]),a)

Here is the output.

Capture.PNG

You also could refer to my attachement.

Best  Regards,

Cherry

 

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

Hello Cherry,

 

Thank you very much!! Your solution was just amazing.

 

Thanks!

Anonymous
Not applicable

Can you try this 

 

Measure=calculate( sum(sales),parellelperiod(Dimdate(date),-1,year))

parry2k
Super User
Super User

@Rate do you have date dimension in your model? if no you need to add one and  there are may posts on how to add one. Also make sure date dimension table is marked as date table .



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.

Top Solution Authors