Forum Discussion

cecytabv's avatar
cecytabv
Frequent Visitor
9 years ago
Solved

Top 5 and others

Hi everyone!   I am interested in knowing how can I create a Top 5 + Others in a database. The others value's sum has to appear in line number 6. Therefore, the chart only has to have 6 lines as yo...
  • OwenAuger's avatar
    OwenAuger
    9 years ago

    Hi cecytabv

     

    The basic change you need to make is to modify the filter context in which the TOPN function is called to be just the latest month.

     

    This way, you will see values for all months, but the TOPN is determined only in the latest month.

     

    The measures should be modified to something like:

     

    Sales Amount Top =
    CALCULATE (
        [Sales Amount],
        KEEPFILTERS (
            CALCULATETABLE (
                TOPN ( [TopN Selection], ALL ( Sales[Customer] ), [Sales Amount] ),
                LASTNONBLANK ( Calendar[Month], 0 )
                // Note: Assumes Calendar[Month] has a natural sort order
                // Could possibly use LASTDATE for a date column
            )
        )
    )

    and similarly for the Other measure.