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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
KJanssens
Helper II
Helper II

circular dependency when adding two independent calculated columns

I have a table with PRODUCTS and a table with SALES (linked to each other with ProductID), and a DATE table (linked to SALES table)

 

I want to calculate the average sold items per product in the last 14 days and the average sold items in the last 28 days:

 

when I add the following two calculated columns to the PRODUCT table:

 

AvgSoldLast14Days = CALCULATE(SUM(SALES[qty]); DATESINPERIOD('Date'[Date]; NOW(); -14; DAY)) / 14
AvgSoldLast28Days = CALCULATE(SUM(SALES[qty]); DATESINPERIOD('Date'[Date]; NOW(); -28; DAY)) / 28
 
 
I get the error "a circular dependency was detected" ... 
why do I get this?
3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Oh the wonders of DAX's refusal to do anything even remotely approaching recursion...

 

Well, it is tough to say. Some mocked up sample data would help. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said, my bet is on DATESINPERIOD doing something funky. You might try getting rid of it and replace it with a simple FILTER statement, FILTER('Date',[Date]>=NOW()-14 && [Date]<=NOW())



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

following on your suggestion to add sample data, I create a simple dataset. However, my sample does not have this problem, so it has something to do with my real-life data dsf ☹️

BTW: how can I add attachments (I don't see any upload button to attach my sample)

HI  @KJanssens 

I have tested on my side, it works well.

Please make sure you add these two calculated column in PRODUCT table not SALES table.

and here is my sample pbix file, please try it.

 

and This is a good refresher on circular dependencies: https://www.sqlbi.com/articles/understanding-circular-dependencies/

For your sample pbix file, yu can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Regards,

Lin

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.