I've gotten a bit stuck trying to figure out how to calculate the smallest difference between a given value and multiple others.
I have a dataset with rates and need to find out what the smallest difference is between that rate and previously known rates for that event.
The number of previously known rates will vary, so I tried using filter to get the array of all previously known rates for a specific event, but I don't know how to combine that with an IF to get the smallest difference. Since I'm not looking for MIN or MAX values, but the closest larger value to my rate to then use to get a difference.
Right now I have this formula in G2:
=IF(C2<>1, MIN(IF(E2:F7>D2, E2:F7))-D2, "")
But this doesn't dynamically change the E:F array to only look up those with the corresponding site in column A. I need a way that will find the correct values in E:F when A:A=A2 for G2, A:A=A8 for G8 etc.
I have a dataset with rates and need to find out what the smallest difference is between that rate and previously known rates for that event.
The number of previously known rates will vary, so I tried using filter to get the array of all previously known rates for a specific event, but I don't know how to combine that with an IF to get the smallest difference. Since I'm not looking for MIN or MAX values, but the closest larger value to my rate to then use to get a difference.
Right now I have this formula in G2:
=IF(C2<>1, MIN(IF(E2:F7>D2, E2:F7))-D2, "")
But this doesn't dynamically change the E:F array to only look up those with the corresponding site in column A. I need a way that will find the correct values in E:F when A:A=A2 for G2, A:A=A8 for G8 etc.