cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
spaxia Regular Visitor
Regular Visitor

Circular Dependency (Driving me Crazy)

Hello,

 

I have a very simple problem that is driving me crazy:

 

I have a Table with the Following semplified Structure

 

ID, Description, Value

1, Mark, 3

2, John, 6

3, Maria, 5

 

I need to add a column not a measure let's call it CALC and essentially the value of CALC for each Row

depend on the Value of the previous row CALC Value. 

 

Whatever I do i Get a Circular Dependency. 

 

Please help!

 

Thank you so much!

 

4 REPLIES 4
Community Support Team
Community Support Team

Re: Circular Dependency (Driving me Crazy)

Hi @spaxia ,

 

You can use a calculated column to do it.

CALC =
CALCULATE (
    FIRSTNONBLANK ( 'Table'[Value], 1 ),
    FILTER ( 'Table', 'Table'[ID] = ( EARLIER ( 'Table'[ID] ) - 1 ) )
)

2-1.PNG

To avoid the Circular Dependency errors, you can refer to this document.

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

 

Best Regards,

Eads

 

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

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

Re: Circular Dependency (Driving me Crazy)

Hello,

 

thank you so much for your help.

 

But actually I want something like:

 

CALC =
CALCULATE (
    FIRSTNONBLANK ( 'Table'[CALC], 1 ),
    FILTER ( 'Table', 'Table'[ID] = ( EARLIER ( 'Table'[ID] ) - 1 ) )
)

 

I would like essentially to calculate CALC based on the Previous CALC available.

 

Thank you so much

Highlighted
Community Support Team
Community Support Team

Re: Circular Dependency (Driving me Crazy)

Hi @spaxia ,

 

There is no recursive concept in DAX.

You have defined CALC with dax, but CALC in dax also needs to use this dax to define it, then it will fall into an endless loop. 
You can refer to the document I attached in the previous answer

 

Best Regards,

Eads

 

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

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

Re: Circular Dependency (Driving me Crazy)

Thank you Eads,

 

actually this is not what i want to achieve. Let me explain with more details:

 

I have the following scenario:

 

PBIWAC.png

 

WAC it's what I want to achieve (i created the result manually) , but i cannot find a way to add such a calculted column. it should be a column since a need to reuse it in other calculations so cannot be a measure.

 

To give an example to calculate WAC or row 2 i do the following

 

(Amount + (Stock * (CALC of previous Row))) / Stock + Qty

 

(40 + (5 * 9)) / 5 + 5

 

Result would be 85/10 = 8,5 

 

And so on...

 

Thank you so much for your help

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 329 members 3,486 guests
Please welcome our newest community members: