Forum Discussion

buttercream's avatar
buttercream
Helper II
2 years ago
Solved

Multiple Top N

Hi,

 

I have 2 tables.

Table1

CategoryProduct
FruitsApple
FruitsBanana
FruitsKiwi
FruitsMango
VegetablesCelery
VegetablesLettuce
VegetablesCarrot
VegetablesOnion
GrainsRice
GrainsBread
GrainsPasta
GrainsBeans
MeatsChicken
MeatsBeef
MeatsTurkey

 

Table 2

DateProductSale
2/5/2024Banana4
2/5/2024Lettuce19
2/5/2024Onion14
2/5/2024Beans5
4/10/2024Lettuce13
4/10/2024Carrot12
4/10/2024Onion18
4/10/2024Mango14
4/10/2024Chicken20
4/10/2024Beef20
4/10/2024Beans15
5/1/2024Beans19
5/1/2024Rice18
5/1/2024Onion12
5/1/2024Lettuce7
5/1/2024Celery17
5/1/2024Carrot18
5/1/2024Banana10

 

I am trying to get a visual that shows top 2 categories for the latest date selected via a date slicer.  Example if no date is selected in slicer would default to 5/1/2024 (latest date).

CategorySale
Vegetables54
Grains37

 

How do I achieve this?

  • Hy buttercream ,

     

    Assuming that you have a DateDimension that is linked to the sales date and assuming that you are linking the two examples based on the Product field; then the Top N will get you want you want.  By doing this version you get it by date:

     

     

     

     

    If you want to ignore the  date, change the top N by Sale instead of Date

     


    If you want to have this done by a specific date, you could use either method and then make a Dax date of "latest date" and then put that into the filter for the visual.

     

     

1 Reply

  • Hy buttercream ,

     

    Assuming that you have a DateDimension that is linked to the sales date and assuming that you are linking the two examples based on the Product field; then the Top N will get you want you want.  By doing this version you get it by date:

     

     

     

     

    If you want to ignore the  date, change the top N by Sale instead of Date

     


    If you want to have this done by a specific date, you could use either method and then make a Dax date of "latest date" and then put that into the filter for the visual.