Forum Discussion

MichalDe's avatar
MichalDe
Frequent Visitor
5 years ago
Solved

Topn with additonal filter

Hi I'm new in Power and I've got a problem with TOPN function with additonal FILTER on Dates. What am I doing wrong in this case?   I want to get the column with TOP 10 customers for all dates (al...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi MichalDe ,

     

    Got it. I have reached your expected in two ways please check.

     

    • Method 1:

    1. Create a table:

     

    Sum top10 table = SUMMARIZE('Date',"Top10", SUMX(TOPN(10, ALL(Customer[Full Name]),[Total Sales],DESC),[Total Sales]) )
    

     

    2. Create a measure:

     

    Top 10 All Time = IF([Total Sales]=BLANK(),BLANK(),MAX('Sum top10 table'[Top10]))

     

     

     

    • Method 2:

    1.Create a new Year table:

     

    New Table = SELECTCOLUMNS(FILTER('Date',[Total Sales]<>BLANK()),"Year",[Year])

     

    2.Create new total sales measure:

     

    new total sales = CALCULATE([Total Sales],FILTER('Date',[Year]=MAX('New Table'[Year])))

     

    3. Top10:

     

    new top10 = SUMX(TOPN(10,ALL(Customer[Full Name]),[Total Sales],DESC),[Total Sales])

     

    The final output is shown below:

     

     

    In addition, when I open your pbix file, an alert dialog shown :  

    It seems that your PBI is in an earlier version, so please upgrade it to the latest version and have a try.

    Download Microsoft Power BI Desktop from Official Microsoft Download Center

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.