Forum Discussion
Get the top items highest to lowest value per month while using filter
- 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
-----
3
5
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.
the issue is if i select the date it will filter also the other chart it will give different top 5 value . I want to show top 5 items each month from highest to lowest. the table above is only sample data and i have more items. the loss chart shows correct value but in gains shows different.