Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
juanmobando
Frequent Visitor

How to calculate percentage change from prior date (prior record)?

I have a data set what has a column for year and one for year.

 

I need to create a variance between the values for each year. How can I get this done? I assume that I have to work on a matrix to show the variance for years, but what formula can I use to be able to calculate it?

 

I tried to see the different options but could not come up to a definitive solution.

 

Any help on the matter would be highly appreciated.

 

My data looks like this:

 

Year

Brand

Sales

2014

A

1200

2014

B

213

2015

A

3234

2015

B

2343

 

 

Ideally I want to have it the veriance (see below). I already have been able to define the matrix and have all but the variance unfortunately 😞 . Thank you lots!!!

 

Brand

2014

2015

% Variance

A

1200

3234

?

B

213

2343

?

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @juanmobando,

 

Could you please mark the proper answer as solution or share the solution if it's convenient for you? That will be a big help to the others.

 

Best Regards!
Dale

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Employee
Employee

Hi @juanmobando,

 

If your data is the same with the sample, you can try this formula. I'm afraid it's hard to create a layout like yours. Maybe you can add two measures. You check it out in this file.

 

Sales2014 =
CALCULATE ( SUM ( Table1[Sales] ), Table1[Year] = 2014 )
Sales2015 =
CALCULATE ( SUM ( Table1[Sales] ), Table1[Year] = 2015 )
Variance =
VAR thisyear =
    MAX ( 'Table1'[Year] )
VAR lastYear =
    CALCULATE (
        MAX ( 'Table1'[Year] ),
        FILTER ( ALL ( 'Table1'[Year] ), 'Table1'[Year] < MAX ( 'Table1'[Year] ) )
    )
VAR lastYearSales =
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER ( ALL ( 'Table1'[Year] ), Table1[Year] = lastYear )
    )
RETURN
    (
        CALCULATE ( SUM ( Table1[Sales] ), Table1[Year] = thisyear )
            - lastYearSales
    )
        / lastYearSales

How to calculate percentage change from prior date (prior record).png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards,

Dale

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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