Forum Discussion

jayceeb's avatar
jayceeb
Icon for Helper I rankHelper I
1 year ago
Solved

Get the top items highest to lowest value per month while using filter

how to Get the top items from highest to lowest value per month while using filter. when i use the TOp N for 5 items its also include the filter for both table. I want to show as per below like in ex...
  • v-csrikanth's avatar
    1 year ago

    Hi jayceeb 

    Thank you for being part of the Microsoft Fabric Community.
    Sorry for the late response.
    Please do follow the below steps that might resolve your issue.
    The most flexible way to show the top N items per month is to rank each item within its month and then filter the visual to that rank. Here’s how:

    Create a Top N parameter table (disconnected) via Enter Data, for example:

    TopN 

    ----- 

    10 

    This lets end-users choose how many items to display.

    Rank items per month with a measure using RANKX:

    Item Rank =

    RANKX(

    FILTER(

    ALLSELECTED( 'YourTable' ),

    'YourTable'[Date] = SELECTEDVALUE( 'YourTable'[Date] )

    ),

    CALCULATE( SUM( 'YourTable'[Loss/Gain] ) ),

    ,

    DESC,

    DENSE

    )

    This evaluates each item’s total value in the currently selected month context SQLBI.

    Build the Top N measure that blanks out lower-ranked items:

    Show TopN Value =

    IF(

      [Item Rank] <= SELECTEDVALUE( TopN[TopN], 5 ),

      CALCULATE( SUM( 'YourTable'[Loss/Gain] ) ),

      BLANK()

    )
    Here SELECTEDVALUE( TopN[TopN], 5 ) pulls in the user’s N choice, defaulting to 5 if none is selected.

    Configure your Matrix visual:

      • Place Date (e.g. Month) on Rows, Description (Item) beneath it.
      • Use Show TopN Value in the Values bucket.
      • The matrix will automatically show, for each month, only those items whose rank is ≤ N, sorted by the value DESC.

    This pattern scales to any number of items and respects page-level or slicer filters on dates.


    If this solves your issue, please give us Kudos and mark it as Accepted as solution.
    Best Regards,
    Community Support Team _ C Srikanth.