Forum Discussion
Jaed
3 years agoFrequent Visitor
DAX: Avoid cyclic dependency
Hi all, I am new to power BI. I am trying to calculate the daily open pieces. I am able to do this in excel, but when copieng to PBI I get a cyclic dependency. Pieces reques...
- 3 years ago
Hi Jaed ,
For this you need to create two different measures:
Pieces Requested + Backlog = VAR temptable = FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < MAX ( 'Table'[Date] ) ) RETURN SUM ( 'Table'[Pieces Requested] ) + SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] ) Backlog = VAR temptable = FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] <= MAX ( 'Table'[Date] ) ) RETURN SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] )If you want to have this based on a column redo the formulas to:
Backlog Column = VAR temptable = FILTER ( 'Table', 'Table'[Date] <= EARLIER( 'Table'[Date] ) ) RETURN SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] ) Pieces Requested + Backlog Column = VAR temptable = FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < EARLIER( 'Table'[Date] ) ) RETURN 'Table'[Pieces Requested] + SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] ) - 3 years ago
Thank you very much 🙂
MFelix
3 years agoSuper User
Hi Jaed ,
For this you need to create two different measures:
Pieces Requested + Backlog =
VAR temptable =
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < MAX ( 'Table'[Date] ) )
RETURN
SUM ( 'Table'[Pieces Requested] )
+ SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] )
Backlog =
VAR temptable =
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
RETURN
SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] )
If you want to have this based on a column redo the formulas to:
Backlog Column =
VAR temptable =
FILTER ( 'Table', 'Table'[Date] <= EARLIER( 'Table'[Date] ) )
RETURN
SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] )
Pieces Requested + Backlog Column =
VAR temptable =
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < EARLIER( 'Table'[Date] ) )
RETURN
'Table'[Pieces Requested]
+ SUMX ( temptable, 'Table'[Pieces Requested] - 'Table'[Pieces Shiped] )
- Jaed3 years agoFrequent Visitor
Thank you very much 🙂