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
prabhupan
Helper I
Helper I

Calculating Variance: Year on Year

Hello, 

 

How do i calculate the variance between the IT spend year on year?

 

I need help with Variance type 1 & 2 given below. 

 

variance.png

 

 

 

 

@ PK
1 ACCEPTED SOLUTION

@prabhupan

 

To calculate the variance between current year and previous year for each account, you can create a calculated column and use EARLIER() function to get the previous year context for calculation. Please refer to formula below:

 

Variance = 
var PreviousYearType1=CALCULATE(SUM(Table1[Type1]),FILTER(Table1,Table1[Account]=EARLIER(Table1[Account]) && Table1[Year]=EARLIER(Table1[Year])-1))
return
IF(PreviousYearType1=BLANK(),BLANK(),Table1[Type1]-PreviousYearType1)

7.PNG

 

 

Regards,

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi

 

 Try the below approach. 

 

Add 3 additional columnAdd 3 additional column

***Replace Table3 with your table name

 

Rank = RANKX(Table3,Table3[Year],,1)

PreviousType1 = LOOKUPVALUE(Table3[Type1],Table3[Rank],Table3[Rank]-1)

PreviousType2 = LOOKUPVALUE(Table3[Type2],Table3[Rank],Table3[Rank]-1)

 

VarianceType1 = IF(ISBLANK(Table3[PreviousType1]),BLANK(),Table3[Type1]-Table3[PreviousType1])

 

VarianceType2 = IF(ISBLANK(Table3[PreviousType2]),BLANK(),Table3[Type2]-Table3[PreviousType2])

 

 

variance.png

thanks @Anonymous for the response. 

 

I have multiple IT accounts, so it doesnt work. 

 

IT ac.png

@ PK

@prabhupan

 

To calculate the variance between current year and previous year for each account, you can create a calculated column and use EARLIER() function to get the previous year context for calculation. Please refer to formula below:

 

Variance = 
var PreviousYearType1=CALCULATE(SUM(Table1[Type1]),FILTER(Table1,Table1[Account]=EARLIER(Table1[Account]) && Table1[Year]=EARLIER(Table1[Year])-1))
return
IF(PreviousYearType1=BLANK(),BLANK(),Table1[Type1]-PreviousYearType1)

7.PNG

 

 

Regards,

so i have this data in which one column is year and the other column is sales

 

Year        Sales

2014        332332332

2015         23223232
2016        2132321332

2017        219389323

 

now i have to calculate the rate of change of the sales from one year to the other

 

the data type for year is Number

sales is revenue

 

how do i do it

Anonymous
Not applicable

Use the Earlier function in DAX, before that sort the year.

 

Reference: http://community.powerbi.com/t5/Desktop/How-to-subtract-current-row-from-prior-row-and-so-on-in-powe...

 

 

 

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.