Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

summing up at higher granularity?

I have two tables as below "LevelsTable" is a kind of dimension with a hierachy of 3 levels: Top, Mid and Low "PotentialTable" contains a number that relates to the second level in the hierar...
  • Anonymous's avatar
    Anonymous
    9 years ago

    If anyone is interested... I was looking at it the wrong way round.

     

    One answer is to SUM on the higher granularity table, checking for each row whether there is any record in the (lower level) related table. 

    I also added a check to make sure we don't query from the lowLevel, which does not make sense in my sample problem.

    It seems to do what I want :manwink:

    a first measure: 

    IsLowLevelFiltered = ISFILTERED ( LevelsTable[LowLevel] )

     

    and the final one: 

    SumOfPotential = IF (
                [IsLowLevelFiltered] = FALSE (),
                CALCULATE (
                    SUM ( PotentialTable[Potential] ),
                    FILTER (
                        ALL ( PotentialTable ),
                        COUNTROWS ( RELATEDTABLE ( LevelsTable ) ) > 0
                    )
                ),
                BLANK()
            )