Forum Discussion

rahul632soni's avatar
rahul632soni
Icon for Helper I rankHelper I
3 years ago
Solved

How to Interpolate Blank Values after lookup with multiple Condition in power BI

Hey  I have a Table 1 which Consist of Eng Speed , Fuel Rate and Power as shown below : Eng Speed(RPM) Power(kW) fuel(kg/h) 2100 221 44.8 2100 220 44.5 2100 211 42.6 2100 20...
  • mohdasaad94's avatar
    mohdasaad94
    3 years ago

    Try this another one:

    se the DAX (Data Analysis Expressions) language to create a calculated column for interpolating the blank values. Since the data you have is not uniformly distributed, you can use a combination of LOOKUPVALUE and X functions to get the desired result.

     

    1. Create a relationship between the two tables in Power BI using the "Eng Speed" column.
    2. In Table 2, create a new calculated column, named "Interpolated Power", using the following DAX formula:
      Interpolated Power =
      VAR CurrentEngSpeed = Table2[ENG_SPEED(RPM)]
      VAR CurrentFuelRate = Table2[ENG_FUEL_RATE(kg/H)]
      VAR LowerBoundPower =
      CALCULATE (
      MAX ( Table1[Power(kW)] ),
      FILTER (
      Table1,
      Table1[Eng Speed(RPM)] = CurrentEngSpeed
      && Table1[fuel(kg/h)] <= CurrentFuelRate
      )
      )
      VAR UpperBoundPower =
      CALCULATE (
      MIN ( Table1[Power(kW)] ),
      FILTER (
      Table1,
      Table1[Eng Speed(RPM)] = CurrentEngSpeed
      && Table1[fuel(kg/h)] >= CurrentFuelRate
      )
      )
      VAR LowerBoundFuelRate =
      CALCULATE (
      MAX ( Table1[fuel(kg/h)] ),
      FILTER (
      Table1,
      Table1[Eng Speed(RPM)] = CurrentEngSpeed
      && Table1[fuel(kg/h)] <= CurrentFuelRate
      )
      )
      VAR UpperBoundFuelRate =
      CALCULATE (
      MIN ( Table1[fuel(kg/h)] ),
      FILTER (
      Table1,
      Table1[Eng Speed(RPM)] = CurrentEngSpeed
      && Table1[fuel(kg/h)] >= CurrentFuelRate
      )
      )
      VAR InterpolatedValue =
      IF (
      NOT ISBLANK ( LowerBoundPower )
      && NOT ISBLANK ( UpperBoundPower ),
      DIVIDE (
      CurrentFuelRate - LowerBoundFuelRate,
      UpperBoundFuelRate - LowerBoundFuelRate
      )
      * ( UpperBoundPower - LowerBoundPower )
      + LowerBoundPower,
      BLANK ()
      )
      RETURN
      InterpolatedValue


    This formula does the following:

    • Defines the current "Eng Speed" and "Fuel Rate" values.
    • Finds the nearest lower and upper bounds for "Power" and "Fuel Rate" in Table 1.
    • Interpolates the "Power" value based on the difference between the current "Fuel Rate" and the lower and upper bounds.
    • Returns the interpolated "Power" value or BLANK() if it cannot be calculated.
    1. The new calculated column "Interpolated Power" will contain the interpolated values based on the data in Table 1.

    Keep in mind that this method assumes that your data in Table 1 is sorted in ascending order by "Fuel Rate". If it's not, you should sort it first.