Forum Discussion

MichelleLash's avatar
MichelleLash
New Member
2 years ago

Circular Dependency Open-Close Balance

I am trying to generate a Balance, but I get a circular dependency.
The Initial Balance (the day the report is consulted will be Day 1) is the sum (Table1[Qty]). Then from second day on, it will be Final Balance
Sales, Sum Table2[Qty Sold] of the corresponding day
Final Balance, it will be Initial Balance - Sales.

Also, the visual is a matrix and it should be possible to get to see the values of Initial Balance, Sales and Final Balance per item.

What im looking for: 

Dax: 

  •  Inventory = Calculate(

    SUM ( 'Table1'[Qty] )
)

 

 

  • Sales = Calculate(

    SUM ( 'Table2'[Qty Sold] )
)

 

  • Initial Balance = IF(

    MAX(Dates[Date]) = TODAY(),

    [Inventory],

    CALCULATE([FinalBalance],PREVIOUSDAY(Dates[Date])

))

 

  • Final Balance = IF(

    MAX(Dates[Date]) = TODAY(),

   [Inventory] - [Sales],

   [Initial Balance] - [Sales]

)



Tables: Table1, Table2 and a calendar table called Dates(columns= Year, Month, Day)

Table 1

ClientItemQtyIDCategory
C01USB250C01_USBInventory
C01LAPTOP15C01_LAPTOPInventory
C01MOUSE35C01_MOUSEInventory

Table 2

DateItemQty SoldID
Friday, 2/9USB120C01_USB
Friday, 2/9LAPTOP10C01_LAPTOP
Friday, 2/9MOUSE20C01_MOUSE
Saturday 2/10USB110C01_USB
Saturday 2/10LAPTOP0C01_LAPTOP
Saturday 2/10MOUSE5C01_MOUSE
Sunday 2/11USB20C01_USB
Sunday 2/11LAPTOP5C01_LAPTOP
Sunday 2/11MOUSE10C01_MOUSE

4 Replies