Loading

How to Implement Linear Interpolation with Sparse Data in Tableau

Udgivelsesdato: Jul 29, 2026
Forudsætning(er)
None
Opgave

Take the following dataset as an example.

 

DimensionMeasure
A100
B200
C
D150
E600
F
G
H400
I200
J
K
L
M250
N500
O1000

 

Because this dataset has missing values along a discrete dimension, a standard line chart will fail to render smoothly—either breaking into disconnected segments or dropping inaccurately to zero.

Standard line chart breaks

Standard line chart dropping to zero

The task is to implement Linear Interpolation to achieve following line chart.

Line chart implemented with linear interpolation

 

 

Trin

To implement linear interpolation with sparse data, create following calculated fields and edit table calculations.

Create Calculated Fields

Select Analysis > Create Calculated Field... to create the following calculation fields

  • 1_existing data INDEX
    IF NOT ISNULL(SUM([Measure])) THEN INDEX() END

  • 2_missing data PREVIOUS INDEX
    IFNULL([1_existing data INDEX],PREVIOUS_VALUE(0))

  • 3_missing data NEXT INDEX
    IFNULL([1_existing data INDEX],PREVIOUS_VALUE(0))

  • 4_missing data INDEX difference
    [3_missing data NEXT INDEX]-[2_missing data PREVIOUS INDEX]

  • 5_missing data INDEX difference to current spot
    INDEX()-[2_missing data PREVIOUS INDEX]

  • 6_missing data PREVIOUS Measure
    IFNULL(SUM([Measure]),PREVIOUS_VALUE(0))

  • 7_missing data NEXT Measure
    IFNULL(SUM([Measure]),PREVIOUS_VALUE(0)) 

  • 8_missing data VALUE difference
    [7_missing data NEXT Measure]-[6_missing data PREVIOUS Measure]

  • 9_Linear Interpolation
    IFNULL(LOOKUP(SUM([Measure]),0),
    [8_missing data VALUE difference]/[4_missing data INDEX difference]*[5_missing data INDEX difference to current spot]+[6_missing data PREVIOUS Measure]
    )

Build the view

  1. Drag Dimension to the Columns shelf
  2. Drag 9_Linear Interpolation to the Rows shelf

Edit Table Calculations

  1. Right-click 9_Linear Interpolation on the Rows shelf, and select Edit Table Calculation...
  2. For Nested Calculations, choose 7_missing data NEXT Measure
  3. For Compute Using, choose Specific Dimensions, and check Dimension
  4. For Sort order, choose
    Custom
    Dimension Minimum
    Descending
  5. For Nested Calculations, choose 3_missing data NEXT INDEX
  6. For Compute Using, choose Specific Dimensions, and check Dimension
  7. For Sort order, choose
    Custom
    Dimension Minimum
    Descending
  8. Close the Table Calculation dialog box

            Vidensartikelnummer

            005389112

            Vedhæftede filer

            Linear Interpolation.twbx

            51 KB

             
            Indlæser
            Salesforce Help | Article