Forum Discussion

admin_xlsior's avatar
admin_xlsior
Post Prodigy
5 years ago
Solved

Why my TOPN does not work ?

Hello guys,

 

Need help on some TOPN function. 

When I have this kind of data relationship:

 

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,

 

 

 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    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.

     

    Best Regards,

    Jay

6 Replies

    • admin_xlsior's avatar
      admin_xlsior
      Post Prodigy

      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,

      • admin_xlsior's avatar
        admin_xlsior
        Post Prodigy

        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

    • admin_xlsior's avatar
      admin_xlsior
      Post Prodigy

      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's avatar
        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.

         

        Best Regards,

        Jay