Forum Discussion
Help with circular reference calculation
- Anonymous4 years ago
Hi Anonymous
What are your original columns? I got Month, Cost, Limit only, then 3 Calculated columns
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]
Hi Anonymous
What are your original columns? I got Month, Cost, Limit only, then 3 Calculated columns
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]
- Anonymous4 years agoNot applicable
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
- Anonymous4 years agoNot applicable
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?