cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper I

## Agregar colunma IF Conditional con DAX

Este es el ejemplo y la coumna C seria respuesta del DAX:

 ID Year Condition Result A 2018 Continue A 2019 Continue A 2020 Continue A 2021 Continue B 2018 Left C 2018 Continue C 2019 Continue C 2020 Continue C 2021 Continue D 2019 new D 2020 left

Muchas gracias y saludos desde Brisbane Australia.

Rosario.

1 ACCEPTED SOLUTION

En primer lugar, cree una nueva tabla:

``````New Table =
VAR _all =
CROSSJOIN ( VALUES ( 'Table'[ID] ), VALUES ( 'Table'[Year] ) )
VAR _t =
_all,
"min",
CALCULATE (
MIN ( 'Table'[Year] ),
FILTER ( _all, [ID] = EARLIER ( 'Table'[ID] ) )
)
)
VAR _maxYear =
MAXX ( ALL ( 'Table' ), [Year] )
RETURN
SELECTCOLUMNS (
FILTER ( _t, [Year] >= [min] && [Year] <= _maxYear ),
"ID", [ID],
"Year", [Year],
"Status", LOOKUPVALUE ( 'Table'[Condition Result], [ID], [ID], [Year], [Year] )
)
``````

A continuación, agregue una nueva columna:

``````Final =
VAR _t =
SUMMARIZE (
FILTER ( 'New Table', [ID] = EARLIER ( 'New Table'[ID] ) ),
[Status]
)
VAR _lastYear =
MAXX (
FILTER (
'New Table',
[ID] = EARLIER ( 'New Table'[ID] )
&& [Status] <> BLANK ()
),
[Year]
)
VAR _lastStatus =
LOOKUPVALUE ( 'New Table'[Status], [ID], [ID], [Year], _lastYear )
RETURN
IF (
[Status] = BLANK (),
IF ( ( "Continue" IN _t ) = FALSE, _lastStatus ),
[Status]
)
``````

Saludos
Eyelyn Qin
Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

3 REPLIES 3

En primer lugar, cree una nueva tabla:

``````New Table =
VAR _all =
CROSSJOIN ( VALUES ( 'Table'[ID] ), VALUES ( 'Table'[Year] ) )
VAR _t =
_all,
"min",
CALCULATE (
MIN ( 'Table'[Year] ),
FILTER ( _all, [ID] = EARLIER ( 'Table'[ID] ) )
)
)
VAR _maxYear =
MAXX ( ALL ( 'Table' ), [Year] )
RETURN
SELECTCOLUMNS (
FILTER ( _t, [Year] >= [min] && [Year] <= _maxYear ),
"ID", [ID],
"Year", [Year],
"Status", LOOKUPVALUE ( 'Table'[Condition Result], [ID], [ID], [Year], [Year] )
)
``````

A continuación, agregue una nueva columna:

``````Final =
VAR _t =
SUMMARIZE (
FILTER ( 'New Table', [ID] = EARLIER ( 'New Table'[ID] ) ),
[Status]
)
VAR _lastYear =
MAXX (
FILTER (
'New Table',
[ID] = EARLIER ( 'New Table'[ID] )
&& [Status] <> BLANK ()
),
[Year]
)
VAR _lastStatus =
LOOKUPVALUE ( 'New Table'[Status], [ID], [ID], [Year], _lastYear )
RETURN
IF (
[Status] = BLANK (),
IF ( ( "Continue" IN _t ) = FALSE, _lastStatus ),
[Status]
)
``````

Saludos
Eyelyn Qin
Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

¿Podría compartir las condiciones que debe calcular esa columna?

Gracias

Samarth

Helper I

Gracias Samarth por tu apoyo, de mi tabla de ejemplo deseo obtener la columna C, Condition Result

Saludos,

Rosario

Announcements

#### 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.