Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi Folks,
I am stuck at this problem. I have the following data:
I need to calculate Top 10% Users (ID) based on the amount for each year (using year as a slicer). Thank you.
ID | Year | Amount |
5487 | 2020 | 205987 |
5487 | 2021 | 152659 |
5487 | 2022 | 548751 |
5459 | 2019 | 326985 |
5459 | 2020 | 321549 |
5459 | 2021 | 547854 |
5459 | 2022 | 652301 |
4589 | 2019 | -987326 |
4589 | 2020 | 12545 |
4589 | 2021 | 54700 |
4589 | 2022 | 264523 |
1021 | 2020 | 8423 |
1021 | 2021 | 45622 |
1021 | 2022 | 187932 |
9856 | 2019 | 32215 |
9856 | 2020 | 910321 |
9856 | 2021 | 212566 |
9856 | 2022 | 10221 |
5658 | 2019 | 102355 |
5658 | 2020 | 6456 |
5658 | 2021 | 15654 |
5658 | 2022 | 48998 |
8799 | 2020 | 178469 |
8799 | 2021 | 54545 |
1023 | 2019 | 81212 |
4665 | 2019 | 851025 |
4665 | 2020 | -25478 |
4665 | 2021 | 5215 |
4665 | 2022 | 11006 |
Solved! Go to Solution.
Hi, @meghansh
You can try the following DAX.
DAX:
Rank =
RANKX (
FILTER ( 'Table', 'Table'[Year] = EARLIER ( 'Table'[Year] ) ),
'Table'[Amount],
,
DESC,
SKIP
)
Filter ID =
VAR _rows =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Year] = SELECTEDVALUE ( 'Table'[Year] ),
ALL ( 'Table' )
)
VAR _10Percent = _rows * 0.1
VAR _result =
IF ( SELECTEDVALUE ( 'Table'[Rank] ) <= _10Percent, 1, 0 )
VAR _result1 =
IF ( _rows < 20 && SELECTEDVALUE ( 'Table'[Rank] ) = 1, 1, 0 )
RETURN
IF ( ISFILTERED ( 'Table'[Year] ), IF ( _rows < 20, _result1, _result ), 1 )
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi,
These measures work
ID count = COUNTROWS(Data)
10% of ID count = ROUNDUP(0.1*[ID count],0)
Total = SUM(Data[Amount])
Measure = CALCULATE([Total],TOPN([10% of ID count],ALL(Data[ID]),[Total]),VALUES(Data[ID]))
Hope this helps.
Hi, @meghansh
You can try the following DAX.
DAX:
Rank =
RANKX (
FILTER ( 'Table', 'Table'[Year] = EARLIER ( 'Table'[Year] ) ),
'Table'[Amount],
,
DESC,
SKIP
)
Filter ID =
VAR _rows =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Year] = SELECTEDVALUE ( 'Table'[Year] ),
ALL ( 'Table' )
)
VAR _10Percent = _rows * 0.1
VAR _result =
IF ( SELECTEDVALUE ( 'Table'[Rank] ) <= _10Percent, 1, 0 )
VAR _result1 =
IF ( _rows < 20 && SELECTEDVALUE ( 'Table'[Rank] ) = 1, 1, 0 )
RETURN
IF ( ISFILTERED ( 'Table'[Year] ), IF ( _rows < 20, _result1, _result ), 1 )
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
77 | |
76 | |
57 | |
36 | |
34 |
User | Count |
---|---|
99 | |
56 | |
56 | |
46 | |
40 |