Forum Discussion
Top 5 and others
- 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.
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.
How do I change this code so that the TOPN is computed for across all dates in the visual instead of only for the last month?