Forum Discussion

EaglesTony's avatar
EaglesTony
Post Prodigy
1 year ago
Solved

Need help in collapsing table on itself

Hi,     I have the following table:     FeatureKey      AddedOrRemovedTotal       Count   ABC                  RemovedFromParent          12   ABC                  AddedToParent                ...
  • DataInsights's avatar
    1 year ago

    EaglesTony,

     

    Try this calculated table:

     

    NewTable = 
    ADDCOLUMNS (
        VALUES ( BaseTable[FeatureKey] ),
        "TotalRemoved",
            CALCULATE (
                SUM ( BaseTable[Count] ),
                BaseTable[AddedOrRemovedTotal] = "RemovedFromParent"
            ),
        "TotalAdded",
            CALCULATE (
                SUM ( BaseTable[Count] ),
                BaseTable[AddedOrRemovedTotal] = "AddedToParent"
            )
    )

     

     

    Add "+ 0" if you want 0 instead of blank:

     

    NewTableWithZero = 
    ADDCOLUMNS (
        VALUES ( BaseTable[FeatureKey] ),
        "TotalRemoved",
            CALCULATE (
                SUM ( BaseTable[Count] ),
                BaseTable[AddedOrRemovedTotal] = "RemovedFromParent"
            ) + 0,
        "TotalAdded",
            CALCULATE (
                SUM ( BaseTable[Count] ),
                BaseTable[AddedOrRemovedTotal] = "AddedToParent"
            ) + 0
    )