Forum Discussion

diouckdiouck's avatar
diouckdiouck
Frequent Visitor
1 year ago
Solved

TOPN by date with other category

hey there,    I want to do a simple top 10 by date and cost as you can see below : However I want to add a "other" column that will contain the sum of cost for all the dates that we do not d...
  • v-csrikanth's avatar
    1 year ago

    Hi diouckdiouck 

    To create a Top N by Date visualization in Power BI that includes an "Others" category to sum the remaining data, follow these steps:

    • Create a Rank measure to rank your dates based on the cost (or relevant metric).
      DateRank = RANKX(ALLSELECTED('YourTable'[Date]), CALCULATE(SUM('YourTable'[Cost])), , DESC, DENSE)
    • Create a Category column to label the Top N dates and group the rest as "Others".
      DateCategory = IF([DateRank] <= N, FORMAT('YourTable'[Date], "yyyy-mm-dd"), "Others")
    • Use the DateCategory in your visualization to display the Top N dates individually and aggregate the remaining dates under "Others".

    If the above information helps you, please give us a Kudos and marked the Accept as a solution.
    Best Regards,
    Community Support Team _ C Srikanth.