Forum Discussion

BachDinh's avatar
BachDinh
Helper I
3 years ago
Solved

Implementing a TopN filter per category

Hi,    I am looking to filter a visual to only include top20 most sold items in each country, but using a either a top N filter based on a sum of net sales to filter products, or a RANKX function i...
  • tamerj1's avatar
    3 years ago

    BachDinh 

    Please try

    Sales Top 20 Products =
    IF (
    NOT ISEMPTY (
    INTERSECT (
    VALUES ( 'Product'[Product Name] ),
    TOPN (
    20,
    CALCULATETABLE ( VALUES ( 'Product'[Product Name] ), ALL ( 'Product' ) ),
    [Total Sales]
    )
    )
    ),
    [Total Sales]
    )