Forum Discussion

cfstout's avatar
cfstout
Regular Visitor
4 years ago
Solved

Help with Measure using RANKX and TOPN

Hi, I have a table that provides the TOP 5 Property names by using slicers for StartDate and Plan.  The table aggregates the count of Sessions and provides a Total.  This would be Total Sessions for ...
  • v-cazheng-msft's avatar
    4 years ago

    Hi cfstout,

     

    You may try this solution.

    Here are the sample data used.

     

    Create a Measure like this.

    TotalSessionsForTop5Properties =
    VAR Top5_Properties =
        TOPN (
            5,
            SUMMARIZE (
                'Table',
                'Table'[Property Name],
                "Num",
                    CALCULATE (
                        COUNT ( 'Table'[Session ID] ),
                        FILTER (
                            ALLEXCEPT('Table','Table'[Property Name]),
                            'Table'[Plan] = SELECTEDVALUE ( 'Table'[Plan] )
                                && 'Table'[StartDate] = SELECTEDVALUE ( 'Table'[StartDate] )
                        )
                    )
            ),
            [Num], DESC
        )
    RETURN
        SUMX ( Top5_Properties, [Num] )

     

    Then, the result looks like this.

     

    Also, attach the pbix file as reference. Hope it helps.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun