Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Data Aggregation from live data

Hi Everyone,   I have a data aggregation question. My data is in following shape (this is just a sample of data for the large dataset) Type Level 4 Level 3 Level 2 Type1 10432 112808 4...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  Anonymous 

    If you want to create calculated column,you can refer to the following code.

     

    Result =
    VAR a =
        SUMMARIZE (
            'Table',
            [Type],
            'Table'[Level 4],
            'Table'[Level 3],
            'Table'[Level 2]
        )
    VAR b =
        COUNTROWS ( FILTER ( a, [Type] = EARLIER ( 'Table'[Type] ) ) )
    RETURN
        SWITCH ( TRUE (), b = 1, "Standalone", b > 1, "Multi Hierarchy" )
    

     

    Output

    If you want to create measure,you can refer to the following code.

    Measure =
    VAR a =
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            [Type],
            'Table'[Level 4],
            'Table'[Level 3],
            'Table'[Level 2]
        )
    VAR b =
        COUNTROWS ( FILTER ( a, [Type] IN VALUES ( 'Table'[Type] ) ) )
    RETURN
        SWITCH ( TRUE (), b = 1, "Standalone", b > 1, "Multi Hierarchy" )
    

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.