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

How do I compare compare dates and values?

I have a SQL query that returns a table at present, see below.

 

I'd like to use Bi to do this rather than a mix of sql and bi. How do i return the current months sales vs the year previous?

 

I see there are many options to do this, all which which fail to weork for me. Any help apprecated.

 

Capture.PNG

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

It sounds like what you want is something along the lines of PARALLELPERIOD

https://support.office.com/en-us/article/PARALLELPERIOD-Function-f38ab5a7-d88c-48a8-9eb2-dc67d5aa3f4...

 

There are also some techniques here that might help:

http://www.daxpatterns.com/time-patterns/

 

 

Not sure what you have tried thus far.

 


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

View solution in original post

I suppose you want to compare januar 2014 to januar 2015. If so, you can use this DAX formula:

 

Prior Year Same Month Sales = CALCULATE(
        SUM([Sales Amount]);
        DATESMTD(SAMEPERIODLASTYEAR(Calendar[DateKey])))

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

It sounds like what you want is something along the lines of PARALLELPERIOD

https://support.office.com/en-us/article/PARALLELPERIOD-Function-f38ab5a7-d88c-48a8-9eb2-dc67d5aa3f4...

 

There are also some techniques here that might help:

http://www.daxpatterns.com/time-patterns/

 

 

Not sure what you have tried thus far.

 


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

Thanks for that. Using the forula below i just get a blank column. Why would this be?

 

YoY = CALCULATE(SUM(order_header_total[oht_foreign_net]),PARALLELPERIOD(order_header[oh_datetime],-1,YEAR))

 

 

Capture.PNG

I suppose you want to compare januar 2014 to januar 2015. If so, you can use this DAX formula:

 

Prior Year Same Month Sales = CALCULATE(
        SUM([Sales Amount]);
        DATESMTD(SAMEPERIODLASTYEAR(Calendar[DateKey])))

Thanks for this. A big help.

You are welcome. Hope it saves your time.

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