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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Help with circular reference calculation

Hello,

 

 I need to perform a difficult calculation on my model and I can not seem to find the answer to this.

 

The context is:

 

Every month I have a total cost, but I have a limit on how much I can pay, if the cost exceeds this limit I have to carry the difference to next month.

 

The problem is that this calculation is giving me the circular reference problem.

 

Illustration of the problem:

 

gfonteles94_0-1638133864963.png

The problem is that the current red row references the previous orange row, which references the previous red row, I have no idea of how to solve this issue on power bi.

 

Can anyone help me?

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

What are your original columns? I got Month, Cost, Limit only, then 3 Calculated columns

Vera_33_0-1638146069244.png

Difference = 
VAR CurMonth = 'Table'[Month]
VAR T1=FILTER('Table','Table'[Month]<=CurMonth)
RETURN
SUMX(T1,[Cost]-[Limit])

Previous Month = 
MAXX(FILTER('Table','Table'[Month]=EDATE( EARLIER('Table'[Month]),-1)),[Difference])

Total = [Cost]+[Previous Month]

 

View solution in original post

3 REPLIES 3
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

What are your original columns? I got Month, Cost, Limit only, then 3 Calculated columns

Vera_33_0-1638146069244.png

Difference = 
VAR CurMonth = 'Table'[Month]
VAR T1=FILTER('Table','Table'[Month]<=CurMonth)
RETURN
SUMX(T1,[Cost]-[Limit])

Previous Month = 
MAXX(FILTER('Table','Table'[Month]=EDATE( EARLIER('Table'[Month]),-1)),[Difference])

Total = [Cost]+[Previous Month]

 

Anonymous
Not applicable

gfonteles94_0-1638151984273.png

Works perfectly! I just included an if statement on the difference to yield '0' if negative, this way we won't accumulate negative values at the difference.

 

 

If you have the time, could you explain to me why this works ??

 

I was trying using Calculate(sum(difference, Filter (previous month)) and it was not working, giving the circular error

Hi @Anonymous 

 

I don't have enough context to understand how you calculated all the values, are they all DAX Calculated columns or measures? Have you checked if there is certain value like referencing each other?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors