Forum Discussion

derekli17001's avatar
derekli17001
Icon for Helper I rankHelper I
1 year ago
Solved

My Matrix Table Keeps Showing More than X rows despite Measures - How to fix?

Hi - Currently my table (named Overview) is displaying Sites (via distinct site table) and Customers (via distinct customer table) as the Matrix Table's rows and the overall store sales + top 5 custo...
  • Jihwan_Kim's avatar
    Jihwan_Kim
    1 year ago

    HI, 

    I am not sure if I understood your question correctly, but in my opinion, only adding top 5 of each store is correctly shown. However, if you still want to show all total, then please try something like below.

    Customer top5 by store =
    VAR BaseTable =
        ADDCOLUMNS (
            CALCULATETABLE (
                SUMMARIZE ( Overview, 'Unique Customers'[Customer], 'Unique Stores'[Store] ),
                REMOVEFILTERS ( 'Unique Customers'[Customer] ),
                ALLSELECTED ( 'Date'[Year] )
            ),
            "@val", CALCULATE ( [Total Sales], ALLSELECTED ( 'Date'[Year] ) )
        )
    VAR Result =
        CALCULATE (
            [Total Sales],
            KEEPFILTERS (
                WINDOW (
                    1,
                    ABS,
                    5,
                    ABS,
                    BaseTable,
                    ORDERBY ( [@val], DESC ),
                    ,
                    PARTITIONBY ( 'Unique Stores'[Store] )
                )
            )
        )
    RETURN
        IF ( NOT ISINSCOPE ( 'Unique Customers'[Customer] ), [Total Sales], Result )