How it works...

We start by getting the current value for the Temp (C) in the R03_Interpolation table within the current context. This is stored in the __x variable and represents the point on the x axis at which we are attempting to perform interpolation. Next, we create the __match variable. The __match variable attempts to find a matching record for the current temperature, __x, within the R03_Table table. If a match is found, __match is assigned the value of the Pressure (MPA) column for the corresponding row in the R03_Table table. Otherwise, if no match is found, __match is assigned the BLANK value.

We now start our first RETURN statement. We first check whether __match is blank (ISBLANK). If __match is blank, then we will need to interpolate. If __match is not blank, then there is no reason to interpolate and we simply return the value of __match. If interpolation is required, we start by calculating the __x0 variable. The __x0 variable represents the temperature value, Temp (C), within the R03_Table table that is the highest temperature that is less than our current temperature value, __x. We can find this by using FILTER to filter the R03_Table table for all rows with a Temp (C) that is less than the current temperature, __x, and then using MAXX to find the maximum value of Temp (C) within this filtered set of rows.

The calculation of the __x1 variable is very similar to the calculation for __x0. The __x1 variable represents the temperature value, Temp (C), within the R03_Table table that is the lowest temperature that is greater than our current temperature value, __x. We can find this by using FILTER to filter the R03_Table table for all rows with a Temp (C) that is greater than the current temperature, __x, and then using MINX to find the minimum value of Temp (C) within this filtered set of rows.

We can now use our values for __x0 and __x1 when calculating the __y0 and __y1 variables. Both __y0 and __y1 are calculated nearly identically to our calculation for __match except that we are now looking up the temperature values for __x0 and __x1, respectively. Our second RETURN statement then simply implements the linear interpolation formula to return the estimated value.