5 closest in proximity for a single column

I have 3 columns. 1 is the our store, 2 is our competitors, and 3 is our competitors proximity to our store. I am trying to use a table to show the 5 closest comps to our stores. How can I use a beastmode to show the 5 closest comps for each store?

Answers

  • GrantSmith
    GrantSmith Indiana 🥷

    You can use a window function in an ETL to calculate the proximity rank where you partition based on your store and order by the proximity distance in ascending order then in your card you can filter for where the rank is <= 5


    Alternatively you can try and do the same thing with a beast mode on the card:

    SUM(SUM(1)) OVER (PARTITION BY `Our Store ID` ORDER BY `Proximity`)
    

    Then put that in the filter where it's <= 5

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**