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
jgorigo
Regular Visitor

Linear interpolation DAX measure

Hola a todos. Agradezco cualquier ayuda que me proporcionen.

 

Tengo 2 tablas: uf_prosp y TBL_CCS_DAP_Test

Las 2 se relacionan con un campo fecha_proceso (31/12/2021 y 31/01/2022) y plazo_residual (número de días)

Esta medida obtiene los valores de esc_1 para el plazo_residual interpolando con los datos de las columnas _plazo y esc_1 de la tabla uf_prosp

La medida funciona correctamente. Pero siempre debe haber una sola fecha, por ejemplo 31/12/2021. Si no filtro la tabla en power query y dejo varias fechas no funciona.
¿Cómo se puede filtrar la medida por fecha?
FD_s =
VAR x3 = max(TBL_CCS_DAP_Test[p_residual])
VAR match = CALCULATE(MAX(uf_prosp[_plazo]),FILTER(uf_prosp,uf_prosp[_plazo]= x3))
VAR x1 = CALCULATE(MAX(uf_prosp[_plazo]),FILTER(uf_prosp,uf_prosp[_plazo] <= x3))
VAR x2 = CALCULATE(MIN(uf_prosp[_plazo]),FILTER(uf_prosp,uf_prosp[_plazo] >= x3))
VAR y1 = LOOKUPVALUE(uf_prosp[esc_1],uf_prosp[_plazo],x1)
VAR y2 = LOOKUPVALUE(uf_prosp[esc_1],uf_prosp[_plazo],x2)
RETURN IF(NOT(ISBLANK(match)), y1,
y1 + (x3 - x1) * (y2 - y1)/(x2 - x1)
)
 uf_prosp y TBL_CCS_DAP_Test
jgorigo_3-1659108227636.pngjgorigo_4-1659108271638.png

 

 

1 ACCEPTED SOLUTION
technolog
Super User
Super User

Hi! You can use logic like this:

VAR CurrentRow = MAX('Calendar'[WEEKINT])
VAR ProductionLW1 = CALCULATE([Value],FILTER(ALL('Calendar'), 'Calendar'[WEEKINT] = CurrentRow - 1))
VAR ProductionLW2 = CALCULATE([Value],FILTER(ALL('Calendar'), 'Calendar'[WEEKINT] = CurrentRow - 2))

View solution in original post

1 REPLY 1
technolog
Super User
Super User

Hi! You can use logic like this:

VAR CurrentRow = MAX('Calendar'[WEEKINT])
VAR ProductionLW1 = CALCULATE([Value],FILTER(ALL('Calendar'), 'Calendar'[WEEKINT] = CurrentRow - 1))
VAR ProductionLW2 = CALCULATE([Value],FILTER(ALL('Calendar'), 'Calendar'[WEEKINT] = CurrentRow - 2))

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.

Top Solution Authors