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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
hchauhan556
Frequent Visitor

how to remove A circular dependency

I got the error of Circular dependency.

codes of two diff measures are. 

 
Inventory =
VAR CurrentMonthInventory = SUM(CurrentInventory[Quantity])
VAR LastMonthInventory = CALCULATE([Ending Inventory], PREVIOUSMONTH('Date'[Date]))

RETURN
IF(CurrentMonthInventory = 0, LastMonthInventory, CurrentMonthInventory)
 
other measure 
 
Ending Inventory =
VAR InvoiceQty = SUM('InvoiceVolumeReport'[Invoice Quantity])
VAR ForecastedQty = SUM('Demand'[ForecastedQty])
VAR AdjustedInventory1 =[Inventory]
VAR PackagingValue = SUM('Packaging'[Value])

RETURN
IF (
   InvoiceQty > ForecastedQty,
   AdjustedInventory1  + PackagingValue,
  AdjustedInventory1  - ForecastedQty + InvoiceQty + PackagingValue
)

ATTACHED SCREENSHOT HAS THE ERROR:


hchauhan556_0-1709386572535.png

 

RELATIONS MA CREATING IS SHOWN IN AS BELOW:-

hchauhan556_1-1709386653354.png

 

3 REPLIES 3
Anonymous
Not applicable

Hi, @hchauhan556 

To remove circular dependency, you can rewrite the calculation logic of LastMonthInventory in Inventory in Ending Inventory to avoid using Inventory directly. For example, redefine and use CurrentMonthInventory in Ending Inventory instead of AdjustedInventory1. The following is a reference DAX expression:

 

EndingInventory =
VAR InvoiceQty =
    SUM ( 'InvoiceVolumeReport'[Invoice Quantity] )
VAR ForecastedQty =
    SUM ( 'Demand'[ForecastedQty] )
VAR CurrentMonthInventory =
    SUM ( CurrentInventory[Quantity] )
VAR PackagingValue =
    SUM ( 'Packaging'[Value] )
RETURN
    IF (
        InvoiceQty > ForecastedQty,
        CurrentMonthInventory + PackagingValue,
        CurrentMonthInventory - ForecastedQty + InvoiceQty + PackagingValue
    )

 

I hope the above DAX can be helpful to you.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

danextian
Super User
Super User

Hi @hchauhan556 ,

 

This is where you problem lies.

Inventory =
VAR CurrentMonthInventory = SUM(CurrentInventory[Quantity])
VAR LastMonthInventory = CALCULATE([Ending Inventory], PREVIOUSMONTH('Date'[Date]))

RETURN
IF(CurrentMonthInventory = 0, LastMonthInventory, CurrentMonthInventory)

 

danextian_0-1709390834217.png

 

Your Inventory measure references Ending Inventory but Ending Inventory also references Inventory.  If you did the same thing in Excel, you'd also get a similar error.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi Danextian

 

both measures are mandatory and dependent on each other. how can I remove circular dependency on that point?

 

kind regards

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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