Forum Discussion
Add mesaures when Column Removed
- 6 years ago
Hi tkrupka ,
Based on your addtional information, we can try to use the following measure and do not need to create other calculate column.
LastDayTankLevel2 = VAR IBXID = LOOKUPVALUE ( IBXs[IBX_ID], IBXs[IBX_Name], SELECTEDVALUE ( IBXs[IBX_Name] ) ) RETURN SUMX ( SELECTCOLUMNS ( FILTER ( ALL ( Tanks ), [fk_IBX_ID] = IBXID ), "tID", [fk_GeneratorName_ID] ), CALCULATE ( LASTNONBLANK ( RunData[DT_Level], 1 ), FILTER ( RunData, AND ( RunData[fk_IBX_ID] = IBXID, RunData[fk_GeneratorName_ID] = [tID] ) ) ) )or the two in one formula version
LastDayTankLevel3 = VAR SelectedTank = SELECTEDVALUE ( Tanks[Tank_Name] ) VAR SelectedGenerator = LOOKUPVALUE ( Tanks[fk_GeneratorName_ID], Tanks[Tank_Name], SelectedTank ) VAR IBXID = LOOKUPVALUE ( IBXs[IBX_ID], IBXs[IBX_Name], SELECTEDVALUE ( IBXs[IBX_Name] ) ) RETURN IF ( ISINSCOPE ( Tanks[Tank_Name] ), CALCULATE ( LASTNONBLANK ( RunData[DT_Level], 1 ), RunData[fk_GeneratorName_ID] = SelectedGenerator ), SUMX ( SELECTCOLUMNS ( FILTER ( ALL ( Tanks ), [fk_IBX_ID] = IBXID ), "tID", [fk_GeneratorName_ID] ), CALCULATE ( LASTNONBLANK ( RunData[DT_Level], 1 ), FILTER ( RunData, AND ( RunData[fk_IBX_ID] = IBXID, RunData[fk_GeneratorName_ID] = [tID] ) ) ) ) )If the result is still not match your expeted one, just figure it out.
BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi tkrupka ,
Based on your addtional information, we can try to use the following measure and do not need to create other calculate column.
LastDayTankLevel2 =
VAR IBXID =
LOOKUPVALUE ( IBXs[IBX_ID], IBXs[IBX_Name], SELECTEDVALUE ( IBXs[IBX_Name] ) )
RETURN
SUMX (
SELECTCOLUMNS (
FILTER ( ALL ( Tanks ), [fk_IBX_ID] = IBXID ),
"tID", [fk_GeneratorName_ID]
),
CALCULATE (
LASTNONBLANK ( RunData[DT_Level], 1 ),
FILTER (
RunData,
AND ( RunData[fk_IBX_ID] = IBXID, RunData[fk_GeneratorName_ID] = [tID] )
)
)
)or the two in one formula version
LastDayTankLevel3 =
VAR SelectedTank =
SELECTEDVALUE ( Tanks[Tank_Name] )
VAR SelectedGenerator =
LOOKUPVALUE ( Tanks[fk_GeneratorName_ID], Tanks[Tank_Name], SelectedTank )
VAR IBXID =
LOOKUPVALUE ( IBXs[IBX_ID], IBXs[IBX_Name], SELECTEDVALUE ( IBXs[IBX_Name] ) )
RETURN
IF (
ISINSCOPE ( Tanks[Tank_Name] ),
CALCULATE (
LASTNONBLANK ( RunData[DT_Level], 1 ),
RunData[fk_GeneratorName_ID] = SelectedGenerator
),
SUMX (
SELECTCOLUMNS (
FILTER ( ALL ( Tanks ), [fk_IBX_ID] = IBXID ),
"tID", [fk_GeneratorName_ID]
),
CALCULATE (
LASTNONBLANK ( RunData[DT_Level], 1 ),
FILTER (
RunData,
AND ( RunData[fk_IBX_ID] = IBXID, RunData[fk_GeneratorName_ID] = [tID] )
)
)
)
)
If the result is still not match your expeted one, just figure it out.
BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.