Next one.... Sorry: how to get nearest value or other solution

Hi!
Sorry for the number of questions, but it’s my first serious app…
So, sorry :slight_smile: and please! HELP!

I calculate a tube’s inner diameter and want to show to the user only one, the biggest tool which will fit into the calculated tube. If-then, less-or-equal is a halfway, I have tools which are not too big. How to eliminate from displaying others than biggest…

Please find screenshot:

I want to add that limiting the collection to 1 or 3 or whatever number of items will not work because sometimes it will be one tool, but in other cases, it can be 10…

Thanks for the ideas, suggestions and any other help!

Your question kind of contradicts itself, because you say that you only want a single result, but in your screenshot you show 3 matches.

Can you clarify that please?

What exactly is your criteria for determining a match?

Update: Actually, I just looked again and it looks like you want to return the largest possible match in each category. Given that, I have a question: Is that a single collection shown in your screen shot with grouping applied, or is it multiple collections?

This is a single collection, grouped by series; in each series can be one or more tools with the same size; and yes I want to return only biggest ones.

Okay, the grouping makes it a bit tricky. This is what I can think of off the top of my head:

  • You will need a separate Helper Table with one row for each of your Series
  • Add a Single Value column to this table that takes the entered Inner Diameter size and applies it to all rows
  • Now add a Query column that targets your Tools table and apply the following filters:
    – Series is This row->Series
    – Inner Diameter is less than This row->Selected Inner Diameter (the Single Value column)
    – ORDER BY Inner Diameter descending
  • Add a Single Value column that takes the first Inner Diameter from the Query column. This should give you the largest diameter match for each Series.
  • Now back in your Tools table, create a Query column that targets your Helper table and apply the following filters:
    – Series is This row->Series
    – Inner Diameter equals This row->Inner Diameter
  • This last Query column can be used as a filter on your Collection. Only show rows where the Query column is not empty.

The above is a fairly convoluted way to get what you want, but as I said the grouping makes it tricky. There may be a simpler way, but thats the best I can come up with without actually having your App in front of me and experimenting further.

1 Like

If I turn off groupping… Do you have a simpler solution?

And answer to this above: huh! it shows so much! For me, the biggest challenge is to catch a “glide-thinking methodology”, and your help is a great tip, which opens a lot of ways. Thanks!

Actually, even if you turn off grouping I don’t think it makes for a simpler solution. Because you still need to get separate matches per Series. So I think you’d still need the Helper table.

OK! Just after dinner, I will start to build this!
Probably… the whole night with obvious bunch of mistakes :slight_smile:

Thank you, Darren!

1 Like

Good luck with it, we’re here if you get stuck.

2 Likes

Try to convert your list to a JSON, and run a loop to generate an array with your conditions using Javascript column… this technique will help you save many columns for this ond some other queries in the future…
Pozdrawiam Tomku.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.