Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
admin_xlsior
Post Prodigy
Post Prodigy

Why my TOPN does not work ?

Hello guys,

 

Need help on some TOPN function. 

When I have this kind of data relationship:

admin_xlsior_0-1605701965206.png

 

Then I create a Top 2 measure based on Item group like this:

Top 2 Amount by item group = CALCULATE(SUM(Transactions[amount]),
                                    TOPN(2,
                                        'Item groups', 'Item groups'[Group],ASC
                                )
)

 

Whereby what I want to show is the TOP 2 item group, what is the mistake, because currently still all item group come out.

The value and the ranking is correct though, only it doesn;t only show 2 of my item group.

 

Thanks,

 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @admin_xlsior ,

 

I create a sample data according to your description and did some test. While using 'group' from 'item groups' table it will show all groups. While using 'group' from 'products' table it will show correct result.

9.PNG

10.PNG

11.PNG

 

Best Regards,

Jay

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@admin_xlsior , I doubt that too. Can check does it work with group in products.

If so the options are merge the product and group in power query as a work around.

 

and Log and issue : https://community.powerbi.com/t5/Issues/idb-p/Issues

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Yup, did tried that, and it is same result, not working. So is it a bug ? Quite strange but let me try to log.

 

Thanks,

Anonymous
Not applicable

Hi @admin_xlsior ,

 

I create a sample data according to your description and did some test. While using 'group' from 'item groups' table it will show all groups. While using 'group' from 'products' table it will show correct result.

9.PNG

10.PNG

11.PNG

 

Best Regards,

Jay

amitchandak
Super User
Super User

@admin_xlsior , Try like

Top 2 Amount by item group = CALCULATE(SUM(Transactions[amount]),
TOPN(2,
'Item groups', 'Item groups'[Group],ASC
), values('Item groups'[Group])
)

 

refer: https://www.youtube.com/watch?v=QIVEFp-QiOk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Unfortunately, it's not working. Noticed on your video, it is coming from same table, is it the cause of it ?

Is TOPN only works on same table ?

 

Thanks,

Sorry, it's not, on your video it is 2 tables, Item and Sales.

But still in my case it's not working, is it because mine is 3 tables ?

 

Thanks

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.