Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Problem aggregating data at different levels

Hello,   I am struggling for a couple of days with a problem that looked simple but I dont manage to solve. I would appreciate your help.    I have a data set that looks like this:  var1 var...
  • sturlaws's avatar
    6 years ago

    Hi, Anonymous ,

     

    not sure what you are trying to do, but here is a possible strategy for you.

    First create separate tables for Table[Var1] and Table[Var2], one table for each. Use these two tables for slicers. Then create measures like this:

    error_x_agg =
    IF (
        ISFILTERED ( Table_Var1[var1] );
        CALCULATE (
            SUM ( 'Table'[n_events] );
            FILTER (
                ALLEXCEPT ( 'Table'; 'Table'[error_x] );
                NOT ( 'Table'[var1] IN VALUES ( Table_Var1[var1] ) ) 
            )
        );
        CALCULATE ( SUM ( 'Table'[n_events] ); ALLEXCEPT ( 'Table'; 'Table'[error_x] ) )
    )

     

    This example only considers var1, you will have to see how you want to handle situations like: filter on Var1 and not Var2 vs filter on Var2 and not on Var1

     

    Cheers,
    Sturla