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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
SummaL
New Member

How to fixe: A circular dependency was detected

I have a Calendar table like below. Only the last two columns are calculated columns.

Column "IsCurrentMonth " is working fine, DAX as below. 

 

IsCurrentMonth =
var currentromonth = 'Calendar'[MonthNo]
var isthismonth = CALCULATE(MIN('Calendar'[MonthNo]),'Calendar'[DATE]=TODAY())
return
if (isthismonth=currentromonth, "Yes", "No")
 
However, Column "IsCurrentWeek" keeps telling me "A circular dependency was detected". Dax as below. I don't think these two columns are related. Is there any "circular dependency"?
Wondering anybody here can help me out on this? Appreciated.
 
IsCurrentWeek =
var currentrowweek = 'Calendar'[Fiscal_Week]
var iscurrentweek = CALCULATE(MIN('Calendar'[Fiscal_Week]),'Calendar'[DATE]=TODAY())
return
if (iscurrentweek=currentrowweek, "Yes", "No")

 

SummaL_1-1642574417685.png

 

 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @SummaL 

I can reproduce the same error.

13.png

I don't know what exactly causes this error, but after encapsulating the condition with ‘filter’, the code can run normally.

IsCurrentWeek =
VAR currentrowweek = 'Calendar'[Fiscal_Week]
VAR iscurrentweek =
    CALCULATE (
        MIN ( 'Calendar'[Fiscal_Week] ),
        FILTER ( 'Calendar', 'Calendar'[DATE] = TODAY () )
    )
RETURN
    IF ( iscurrentweek = currentrowweek, "Yes", "No" )


14.png

 

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi, @SummaL 

I can reproduce the same error.

13.png

I don't know what exactly causes this error, but after encapsulating the condition with ‘filter’, the code can run normally.

IsCurrentWeek =
VAR currentrowweek = 'Calendar'[Fiscal_Week]
VAR iscurrentweek =
    CALCULATE (
        MIN ( 'Calendar'[Fiscal_Week] ),
        FILTER ( 'Calendar', 'Calendar'[DATE] = TODAY () )
    )
RETURN
    IF ( iscurrentweek = currentrowweek, "Yes", "No" )


14.png

 

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@SummaL , same name seems like an issue, try like

 

IsCurrentWeek =
var _currentrowweek = 'Calendar'[Fiscal_Week]
var _iscurrentweek = CALCULATE(MIN('Calendar'[Fiscal_Week]),'Calendar'[DATE]=TODAY())
return
if (_iscurrentweek=_currentrowweek, "Yes", "No")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

If renaming the variables doesn't sort it have a read of 

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

 

In summary when you use CALCULATE in the second calculated column it causes a context transition and moves all columns from the current row into the filter context. That includes the other calculated columns so they end up being circular.

 

You need to add ALLEXCEPT into the calculate to reference just the column(s) you need to use.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.