Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Dynamic TopN with RankX

Hello everyone,   I have a base with a lot of products, and i want to show the sales of each product along the time in a line chart.  To make the chart more clean, i want to make a dynamic top filt...
  • Anonymous's avatar
    Anonymous
    7 years ago

    It is unclear on what you mean with "make it work different".

     

    Are you trying to show the 4 items with the highest total sales over a year? or just during the month?

     

    EDIT: 

    If took your example file and created the following measure:

    SubTotal = CALCULATE(SUM(Base[Valor Total]);ALLEXCEPT(Base;Base[marca]))

    I then changed your TopN Measure to:

    TopN_total_sales = 
    VAR SelectedTop = SELECTEDVALUE('TopN'[TopN])
    var RankMarca = RANKX(ALL(Base[marca]);[SubTotal])
    
    RETURN
    IF(RANKX(ALL(Base[marca]);[SubTotal])<=SelectedTop;[total_sales];BLANK())

     

    I'll get this as a result:

    Result

    I hope that this solves your problem!

     

    Kind Regards.

     

    PS: If it does solve your problem please mark this as answer.