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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mcstunner
New Member

Linear Interpolation of Multiple Data Series

Hello,

I am trying to create individual linear interpolations on multiple data series, and then average the resulting interpolations.  I have a simple data set below, but my actual data set is very large with hundreds of series' and thousands of values.

 

SeriesX Value  Y Value  
Series 1   220
Series 1420
Series 1620
Series 1820
Series 2330
Series 2630
Series 2930
Series 21230

 

I have created a separate DIM table with a column of numbers from 1 to 12 that I would like to interpolate against as my x-axis.  I would like to create a measure that interpolates each series, and would like to average the resulting interpolations.  Any thoughts would be greatly appreciated.  

 

The Linear Interpolation Post  by  @gregdeckler has gotten me close, but only meets the intended purpose if I have one series of data.  Thanks in advance for any insights!!

 

Mike

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@mcstunner Yikes! That formula is due for an overhaul anyway. Try this, PBIX is attached below signature.

Series 1 = 
    VAR __Table = FILTER('Table',[Series] = "Series 1")
    VAR __x3 = [Column1]
    VAR __match = MAXX(FILTER(__Table,[X Value] = __x3),[Y Value])
    VAR __x1 = MAXX(FILTER(__Table,[X Value] < __x3),[X Value])
    VAR __x2 = MINX(FILTER(__Table,[X Value] > __x3),[X Value])
    VAR __y1 = MAXX(FILTER(__Table,[X Value] = __x1), [Y Value])
    VAR __y2 = MAXX(FILTER(__Table,[X Value] = __x2), [Y Value])
    VAR __Result = IF( __match <> BLANK(),__match, __y1 + DIVIDE((__x3 - __x1) * (__y2 - __y1), (__x2 - __x1)))
RETURN
    __Result



Series 2 = 
    VAR __Table = FILTER('Table',[Series] = "Series 2")
    VAR __x3 = [Column1]
    VAR __match = MAXX(FILTER(__Table,[X Value] = __x3),[Y Value])
    VAR __x1 = MAXX(FILTER(__Table,[X Value] < __x3),[X Value])
    VAR __x2 = MINX(FILTER(__Table,[X Value] > __x3),[X Value])
    VAR __y1 = MAXX(FILTER(__Table,[X Value] = __x1), [Y Value])
    VAR __y2 = MAXX(FILTER(__Table,[X Value] = __x2), [Y Value])
    VAR __Result = IF( __match <> BLANK(),__match, __y1 + DIVIDE((__x3 - __x1) * (__y2 - __y1), (__x2 - __x1)))
RETURN
    __Result

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@mcstunner Yikes! That formula is due for an overhaul anyway. Try this, PBIX is attached below signature.

Series 1 = 
    VAR __Table = FILTER('Table',[Series] = "Series 1")
    VAR __x3 = [Column1]
    VAR __match = MAXX(FILTER(__Table,[X Value] = __x3),[Y Value])
    VAR __x1 = MAXX(FILTER(__Table,[X Value] < __x3),[X Value])
    VAR __x2 = MINX(FILTER(__Table,[X Value] > __x3),[X Value])
    VAR __y1 = MAXX(FILTER(__Table,[X Value] = __x1), [Y Value])
    VAR __y2 = MAXX(FILTER(__Table,[X Value] = __x2), [Y Value])
    VAR __Result = IF( __match <> BLANK(),__match, __y1 + DIVIDE((__x3 - __x1) * (__y2 - __y1), (__x2 - __x1)))
RETURN
    __Result



Series 2 = 
    VAR __Table = FILTER('Table',[Series] = "Series 2")
    VAR __x3 = [Column1]
    VAR __match = MAXX(FILTER(__Table,[X Value] = __x3),[Y Value])
    VAR __x1 = MAXX(FILTER(__Table,[X Value] < __x3),[X Value])
    VAR __x2 = MINX(FILTER(__Table,[X Value] > __x3),[X Value])
    VAR __y1 = MAXX(FILTER(__Table,[X Value] = __x1), [Y Value])
    VAR __y2 = MAXX(FILTER(__Table,[X Value] = __x2), [Y Value])
    VAR __Result = IF( __match <> BLANK(),__match, __y1 + DIVIDE((__x3 - __x1) * (__y2 - __y1), (__x2 - __x1)))
RETURN
    __Result

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.