Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rahul632soni
Helper I
Helper I

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)
210022144.8
210022044.5
210021142.6
210020240.7
210019338.9
210018537.2
210017635.4
210016733.7
210015832.0
210014930.3
210014128.7
210013227.2
210012325.6
210011424.0
210010622.4
21009720.8
21008819.1
21007917.6
21007016.0
21006214.5
21005312.9
21004411.4
2100359.9
2100268.4
2100187.0
210095.5

 

I have another tabel 2 which has only Eng Speed and Fuel rate as shown below :

ENG_SPEED(RPM)ENG_FUEL_RATE(kg/H)
1098.57.9272
1117.57.4664
10005.0904
10003.4416
10003.456
10003.3912
10003.3696
10003.3696
10004.824
1112.54.8672
10003.5856
10003.5496
10002.88
10003.3408
10002.88
1069.54.0824
10584.0968
11736.7248
11946.7536
11607.7976
13527.812
10004.0104
10003.9384
10002.8584

I have lookup Power From 1st table to 2nd Table using eng speed and Fuel rate conditions however we got lots of blnak values , so for blank values of power how can we interpolate using (eng speed and fuel rate ) from table 1.

 

Thanks 

1 ACCEPTED SOLUTION

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.

View solution in original post

4 REPLIES 4
mohdasaad94
Helper I
Helper I

You can use the INTERPOLATE function in DAX to interpolate the blank values of Power based on the values of Eng Speed and Fuel Rate in Table 2. Here's an example DAX formula you can use:

 

Interpolated Power =
VAR EngSpeed = Table2[ENG_SPEED(RPM)]
VAR FuelRate = Table2[ENG_FUEL_RATE(kg/H)]
VAR Interpolated =
INTERPOLATE(
FILTER(Table1, Table1[Eng Speed(RPM)] = EngSpeed),
FuelRate,
Table1[Power(kW)]
)
RETURN
IF(ISBLANK(Table2[Power]), Interpolated, Table2[Power])

 

In this formula, we first define variables for Eng Speed and Fuel Rate from Table 2. Then we use the INTERPOLATE function to interpolate the Power values from Table 1 based on the Fuel Rate and the matching Eng Speed in Table 2. Finally, we use the IF and ISBLANK functions to return the interpolated Power value only for blank values in Table 2, and the original Power value for non-blank values.

@mohdasaad94 

Its not working ,  have already tried chatGPT Solution

 

Thanks

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.

@mohdasaad94 

 

Hey Its Working Fine but i am getting around 60% Blank Value in Iterpolated Power Column after uaing this Dax 

 

Can you please Help ?

Regards

Rahul

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.