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
trovisco
Helper I
Helper I

Calcular el valor de interpolación para cada día del mes dado como valor de entrada sólo durante 3 días

Hola a todos,

Tengo una tabla "Predicción de duración del evento" con valores de [Duración] para 01.01.2020 , 15.01.2020 y 31.01.2020 (se muestra a continuación)

B1.jpg

Tengo una tabla de "Fechas" con [Fecha] de 01.01.2020 a 31.01.2020 (que se muestra a continuación) y hay una Relación de Fecha entre ambos.B2.jpg

A continuación planteo en el eje X mi "Tabla de fechas" [Fecha], y como eje Y mi "Predicción de duración del evento" [Duración] .

Mi objetivo es poder calcular (Interpolar) la Duración de cada día en la tabla [Fechas] (valores que se muestran a continuación como Naranja a continuación)

Por el momento sólo tengo los 3 valores representados como rojosb3.jpg

¿Alguna idea de cómo lograr eso?

Gracias de antemano,

Rui

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hola @trovisco (Rui),

Mirando la entrada de blog puedes adaptar el código a los siguientes https://community.powerbi.com/t5/Quick-Measures-Gallery/Linear-Interpolation/m-p/330712:

(gracias @Greg_Deckler )

Cree una medida con la sintaxis siguiente:

Interpolated Value = 
VAR x3 = MAX(Dates[Date])
VAR match = CALCULATE(MAX('Event Duration Prediction'[Duration]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]=x3))
VAR x1 = CALCULATE(MAX('Event Duration Prediction'[Date]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]<=x3))
VAR x2 = CALCULATE(MIN('Event Duration Prediction'[Date]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]>=x3))
VAR y1 = CALCULATE(MAX('Event Duration Prediction'[Duration]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]<=x3))
VAR y2 = CALCULATE(MIN('Event Duration Prediction'[Duration]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]>=x3))
RETURN IF(NOT(ISBLANK(match));match;y1 + (x3 - x1) * (y2 - y1)/(x2 - x1))

Tenga en cuenta que el truco es no tener la tabla Date y la tabla Events relacionadas entre sí.

interpolado.gif

Cualquier pregunta, por favor, dígame.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hola @trovisco (Rui),

Mirando la entrada de blog puedes adaptar el código a los siguientes https://community.powerbi.com/t5/Quick-Measures-Gallery/Linear-Interpolation/m-p/330712:

(gracias @Greg_Deckler )

Cree una medida con la sintaxis siguiente:

Interpolated Value = 
VAR x3 = MAX(Dates[Date])
VAR match = CALCULATE(MAX('Event Duration Prediction'[Duration]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]=x3))
VAR x1 = CALCULATE(MAX('Event Duration Prediction'[Date]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]<=x3))
VAR x2 = CALCULATE(MIN('Event Duration Prediction'[Date]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]>=x3))
VAR y1 = CALCULATE(MAX('Event Duration Prediction'[Duration]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]<=x3))
VAR y2 = CALCULATE(MIN('Event Duration Prediction'[Duration]);FILTER('Event Duration Prediction';'Event Duration Prediction'[Date]>=x3))
RETURN IF(NOT(ISBLANK(match));match;y1 + (x3 - x1) * (y2 - y1)/(x2 - x1))

Tenga en cuenta que el truco es no tener la tabla Date y la tabla Events relacionadas entre sí.

interpolado.gif

Cualquier pregunta, por favor, dígame.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Gracias @MFelix, funciona perfectamente 🙂

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.