Forum Discussion

tkrupka's avatar
tkrupka
Resolver II
6 years ago
Solved

Add mesaures when Column Removed

I am trying to figure out how to set a sum of my measures when I remove one of the columns from my visual.     So if you look at the picture above, there is a measure titled 'LastDayTankLeve...
  • v-lid-msft's avatar
    v-lid-msft
    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.