Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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]"
ProjectID | Final Cost | Modified | Index | Rank | Difference |
15008 | 0 | 10/2/21 | 22 | 1 | 0 |
15008 | 1500 | 10/8/21 | 120 | 2 | 1500 |
15008 | 1400 | 10/25/21 | 462 | 3 | (100) |
15008 | 7500 | 11/3/21 | 1053 | 4 | 6100 |
15008 | 7500 | 11/4/21 | 1134 | 5 | 0 |
15008 | 0 | 11/6/21 | 1372 | 6 | (7500) |
Solved! Go to Solution.
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:
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/
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:
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/
Thank you so much!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
8 |