Drew Swiney
Drew Swiney

Reputation: 1

Self-reference a column in DAX or Power Query

I am looking to create column D of the table below in power query or DAX. You can see the excel formula in the cell. I need to add columns from the current row and add a previously calculated row above. The column is self-referencing. I am stuck and do not know how to proceed. Any help would be appreciated.

Picture of Excel Data

Upvotes: 0

Views: 1803

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

You cannot recursively self-reference a column in DAX. See here for more detail on that.

That said, just like the examples linked in that post (also below), you don't really need recursion for your purpose but rather a cumulative total of Production - Demand plus an initial inventory amount.

That is, something like this:

Projected Inv. =
CALCULATE (
    SUM ( Table1[Production] ) - SUM ( Table1[Demand] ),
    FILTER ( Table1[Date], Table1[Date] <= MAX ( Table1[Date] ) )
) + 174408

How to perform sum of previous cells of same column in PowerBI

DAX - formula referencing itself

Upvotes: 1

Related Questions