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
MartijnB
Regular Visitor

Calculate difference between data of a 'baseline/reference' year/month and later year/month

Hi guys,

 

This is my first message in the Power BI community.

 

I have imported a SharePoint list which contains energy consumption figures (like: gas, electricity, etc.) per site, per month, as per 2013 till now. Now I am looking for a calculation which calculates the difference between the figures of a 'baseline/reference' year/month, with figures of the same month of a later year, so for example:

  • Jan - 2013 vs. Jan - 2017
  • Apr - 2013 vs. Apr - 2018 and so on

I can create a year over year comparison, but I don’t know how to ‘fix’ (like the $-$ in Excel) the baseline year. I tried Dateadd, but the number of years will vary (2014 vs. 2013 = -1, but 2018 vs. 2013 = -5). Furthermore, I was also thinking about creating a separate table for the baseline year, but then I didn’t got the time intelligence to work.

 

I hope you can help me, thanks!

 

Regards,

Martijn

 

Printscreen of datasetPrintscreen of dataset

1 ACCEPTED SOLUTION

Hi Cherie,

 

Thanks for your reply! Unforunatly I couldn't get your two measures to work, but I found an other solution via the seperate 2013 dataset I created. Via 'Lookupvalue' I get the 2013 values in the original dataset per site and month. After that, it was easy to create the difference calculation.

 

So issue solved. Thanks for your help!

View solution in original post

3 REPLIES 3
v-cherch-msft
Employee
Employee

Hi @MartijnB 

You may try to create the two measures like below.For example:

2013 = CALCULATE(SUM(Data[value]),FILTER(Data,YEAR(Data[date])=2013))
2018 =
CALCULATE (
    SUM ( Data[value] ),
    FILTER (
        ALL ( Data ),
        YEAR ( Data[date] )
            = YEAR ( MAX ( Data[date] ) ) + 5
            && MONTH ( Data[date] ) = MONTH ( MAX ( Data[date] ) )
    )
)

a1.png

Regards,

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

Hi Cherie,

 

Thanks for your reply! Unforunatly I couldn't get your two measures to work, but I found an other solution via the seperate 2013 dataset I created. Via 'Lookupvalue' I get the 2013 values in the original dataset per site and month. After that, it was easy to create the difference calculation.

 

So issue solved. Thanks for your help!

Hi @MartijnB 

Glad to hear you've solved it, please accept the reply as solution to close this thread.

Regards,

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

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.