Forum Discussion
Find previous row using index on a filtered table
- 1 year ago
Hi jefflynn
If I understand correctly, can you achieve this with a calculated column using DAX
CostToComplete_Column =
VAR PreviousRow =
MAXX(
FILTER(Query1, Query1[Index] < EARLIER(Query1[Index])),
Query1[Index]
)VAR PreviousEstCostAgg =
LOOKUPVALUE(Query1[EstCostAgg], Query1[Index], PreviousRow)VAR PreviousActualCostAgg =
LOOKUPVALUE(Query1[ActualCostAgg], Query1[Index], PreviousRow)RETURN
IF(
SEARCH("SUB LABOR", Query1[Description2], 1, 0) > 0,
PreviousEstCostAgg + Query1[EstCostAgg] - (Query1[ActualCostAgg] + PreviousActualCostAgg),
BLANK()
)Find the seccenshot below
If this response was helpful, please accept it as a solution and give kudos to support other community members
Hi jefflynn
If I understand correctly, can you achieve this with a calculated column using DAX
CostToComplete_Column =
VAR PreviousRow =
MAXX(
FILTER(Query1, Query1[Index] < EARLIER(Query1[Index])),
Query1[Index]
)
VAR PreviousEstCostAgg =
LOOKUPVALUE(Query1[EstCostAgg], Query1[Index], PreviousRow)
VAR PreviousActualCostAgg =
LOOKUPVALUE(Query1[ActualCostAgg], Query1[Index], PreviousRow)
RETURN
IF(
SEARCH("SUB LABOR", Query1[Description2], 1, 0) > 0,
PreviousEstCostAgg + Query1[EstCostAgg] - (Query1[ActualCostAgg] + PreviousActualCostAgg),
BLANK()
)
Find the seccenshot below
If this response was helpful, please accept it as a solution and give kudos to support other community members