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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ConnorH
Microsoft Employee
Microsoft Employee

Help fixing circular dependency

I am trying to find the difference between each row given that project IDs are the same and the rank is in order.

 

[Rank] = Rankx(filter('Final Cost Log', 'Final Cost Log'[ProjectID] = EARLIER('Final Cost Log'[ProjectID])), 'Final Cost Log'[Index])
[Difference] = 
var preValue = CALCULATE(VALUES('Final Cost Log'[Final Cost]), FILTER('Final Cost Log','Final Cost Log'[ProjectID] = EARLIER('Final Cost Log'[ProjectID]) && 'Final Cost Log'[Rank] = (EARLIER('Final Cost Log'[Rank]))-1))
Var difference = 'Final Cost Log'[Final Cost] - preValue
return difference

When trying pressing enter for the [Difference] column I recieve this error "A circular dependency was detected: Final Cost Log[Difference]"

 

ProjectIDFinal CostModifiedIndexRankDifference
15008010/2/212210
15008150010/8/2112021500
15008140010/25/214623(100)
15008750011/3/21105346100
15008750011/4/21113450
15008011/6/2113726(7500)
1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @ConnorH 

 

Try this code to add a new column:

 

Difference = 
Var _Previous = CALCULATE(sum([Final Cost]),filter(all('Final Cost Log'),[Rank]=EARLIER('Final Cost Log'[Rank])-1))
return
[Final Cost]-_Previous

 

Update your RANK column code with this:

Rank = Rankx(filter('Final Cost Log', 'Final Cost Log'[ProjectID] = EARLIER('Final Cost Log'[ProjectID])), 'Final Cost Log'[Index],,ASC)

 

Output:

VahidDM_0-1636589599110.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @ConnorH 

 

Try this code to add a new column:

 

Difference = 
Var _Previous = CALCULATE(sum([Final Cost]),filter(all('Final Cost Log'),[Rank]=EARLIER('Final Cost Log'[Rank])-1))
return
[Final Cost]-_Previous

 

Update your RANK column code with this:

Rank = Rankx(filter('Final Cost Log', 'Final Cost Log'[ProjectID] = EARLIER('Final Cost Log'[ProjectID])), 'Final Cost Log'[Index],,ASC)

 

Output:

VahidDM_0-1636589599110.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

ConnorH
Microsoft Employee
Microsoft Employee

Thank you so much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.