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
jvandyck
Helper IV
Helper IV

Show sales for last 'X' months and Same Period Last Year

We are now September 2018. I have data from January 2017 up to July 2018. I would like to create a measure calculating the sum of Jan 2017 up to July 2017 and another one calculating Jan 2018 up to July 2018. I do have a date tabel joined to the fact table.

 

Thanks for your help!

2 ACCEPTED SOLUTIONS

Hi @jvandyck,

 

I made one sample for your reference.

 

 

2017 = TOTALYTD(SUM(Table1[Sales]),SAMEPERIODLASTYEAR(Table1[YYYYMM.1]))
2018 = TOTALYTD(SUM(Table1[Sales]),Table1[YYYYMM.1])

Capture.PNG

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Hi @jvandyck,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Sample data would help. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said, you can try your luck with the time intelligence functions like SAMEPERIODLASTYEAR. Or, you might have better luck with my Time Intelligence The Hard Way Quick Measure: https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Simplified it boils down to this:

YYYYMMSales
20170110
20170215
20170318
20170420
20170590
20170650
20170744
20170866
20170921
20171099
20171122
20171214
20180119
20180233
20180325
20180414
20180516
20180618
20180720

 

This is the data I have. If I create the normal YTD measures, it will take the values from 201801 up to 201807, but doing this for prev year, it would take the data from 201701 up to 201709. This is not what I want, I want up to 201707.

 

So the YTD for this year should be 145 and prev year 247.

 

 

Hi @jvandyck,

 

I made one sample for your reference.

 

 

2017 = TOTALYTD(SUM(Table1[Sales]),SAMEPERIODLASTYEAR(Table1[YYYYMM.1]))
2018 = TOTALYTD(SUM(Table1[Sales]),Table1[YYYYMM.1])

Capture.PNG

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @jvandyck,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I am not able to tie this back to my issue. Looks like overkill to me?

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
Top Kudoed Authors