Skip to main content
Question

Find numeric value closest to specified number

  • March 19, 2019
  • 2 replies
  • 146 views

Hi there,

I have three groups of data (Group A, B and C). The groups have different amounts of total kilometers.

Group A has a total of 890 km, Group B has a total of 770 km and Group C has a total of 849 km. Is there a transformer that can detect/specify which group has the closest amount of kilometers to a specific value defined by me via a parameter? Example: If 850 km is filled into the parameter, Group C with 849 km would be the best candidate.

Thank you!

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

ebygomm
Influencer
Forum|alt.badge.img+45
  • Influencer
  • March 19, 2019

You can work out the difference between the total and your parameter using an expression evaluator, then sort by this value in ascending order and keep the first (lowest) value with a duplicate remover.

Expression to use to calculate the difference would be something like this

@abs(@Value(Total)-$(Parameter_Total))

 


You can work out the difference between the total and your parameter using an expression evaluator, then sort by this value in ascending order and keep the first (lowest) value with a duplicate remover.

Expression to use to calculate the difference would be something like this

@abs(@Value(Total)-$(Parameter_Total))

 

Thank you! It worked!