Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Folks,
Need expertise for one of the problem statement.
I have data shown below. Where we have year , states and sales.
Output expected is also shown , which is to have yearly view with top4 values within each year should be shown below, each value should be shown in separate columns,
Tried using rank but no success. Please share your expertise.
Solved! Go to Solution.
Hi @sumitsingla12 ,
Assuming the desired output is a visual, we need a way to filter each column by the value of the rank. Using EnterData create a table with a column called Rank and enter the values 1 through 4.
Put this in your Columns section of a Matrix and the Year in the rows (this will error for now).
Now create a measure that will read the Rank value and use this as a filter and put it in the values section of the visual:
Rank by sales =
VAR curRank =
SELECTEDVALUE ( 'Rank Table'[Rank] ) --Holds the single rank value in column
VAR SalesYear =
FILTER (
'Data Table',
--Filtered by Year in output visual
RANKX (
--Generate rank for each row in DataTable
'Data Table',
[Sales] --Sort by sales
,
,
DESC --largest sales first
,
DENSE -- If 2 values have 1st place, 3rd value gets 2nd place
) = curRank
) --Filter to visual row year
RETURN
MAXX ( salesyear, 'Data Table'[Sales] )
--Return highest rank
If you are happy with this answer please mark as a solution for others to find !
Kudos are always appreciated! Check out our free Power BI video courses.
Hi @SamWiseOwl ,
Thanks much , it is working for me,
Just curious to know how Power BI is executing this.
I know am asking too much but this will help me understand as to how this calculation is executing.
Thanks again for this help.
Hi @sumitsingla12 ,
My pleasure, if you could mark it as an answer that would be appreciated!
If you search up on YouTube - Wise Owl Training we have a free video course on DAX, might be worth a watch!
If you are happy with this answer please mark as a solution for others to find !
Kudos are always appreciated! Check out our free Power BI video courses.
Hi @sumitsingla12 ,
Assuming the desired output is a visual, we need a way to filter each column by the value of the rank. Using EnterData create a table with a column called Rank and enter the values 1 through 4.
Put this in your Columns section of a Matrix and the Year in the rows (this will error for now).
Now create a measure that will read the Rank value and use this as a filter and put it in the values section of the visual:
Rank by sales =
VAR curRank =
SELECTEDVALUE ( 'Rank Table'[Rank] ) --Holds the single rank value in column
VAR SalesYear =
FILTER (
'Data Table',
--Filtered by Year in output visual
RANKX (
--Generate rank for each row in DataTable
'Data Table',
[Sales] --Sort by sales
,
,
DESC --largest sales first
,
DENSE -- If 2 values have 1st place, 3rd value gets 2nd place
) = curRank
) --Filter to visual row year
RETURN
MAXX ( salesyear, 'Data Table'[Sales] )
--Return highest rank
If you are happy with this answer please mark as a solution for others to find !
Kudos are always appreciated! Check out our free Power BI video courses.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 37 | |
| 35 | |
| 34 | |
| 27 |
| User | Count |
|---|---|
| 134 | |
| 101 | |
| 71 | |
| 67 | |
| 65 |