Find the Index of the Minimum Difference in the List

I have this list in Coda

[0.083, 0.25, 0]

I applied the formula below to the list.

thisRow.[Dummy 2].FormulaMap(AbsoluteValue(CurrentValue-.50))

The result is

0.417, 0.25, 0

Now I want to find the index in the list that gives the minimum difference. In the case above it should be 3. How to do that ?

Try this formula:

thisRow.[Dummy 2].FormulaMap(AbsoluteValue(CurrentValue-.50))
  .WithName(difs, 
  difs.Find(Min(difs))
  )

The Find function returns the index of the first matching element (or -1 if not found).

3 Likes

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