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
Syndicate_Admin
Administrator
Administrator

Uso de múltiples variables en la misma medida

Hola a todos

He pasado por algunas publicaciones relacionadas en este Foro y SQL BI y escribí la siguiente expresión DAX usando varias variables para la medida:

Test_Measure =
Var Res_2 = FILTER('M1 Notifications', ('M1 Notifications'[Creado en] < (TODAY()-1825) && 'M1 Notifications'[Creado en] > (TODAY()-365))
Var Res_1 = FILTER(Res_2, ('M1 Notifications'[Notification System Status] = "Notificaciones pendientes" || 'Notificaciones M1'[Estado del sistema de notificación] = "Pedido asignado" || 'Notificaciones M1'[Estado del sistema de notificación] = "Notificación en curso"))
devolución
IF(COUNTROWS(Res_1) <> BLANK(),COUNTROWS(Res_1),UNICHAR((32))
)
Utilicé dos variables para filtrar la misma tabla sucesivamente para diferentes criterios. Esto es básicamente un filtro AND.
Tengo un error de sintaxis para Var Res_1. No estoy seguro de cómo podemos usar ambas variables en lugar de escribir una expresión de filtro larga que combina todas las condiciones. Para Var Res_1, ¿puedo usar la tabla filtrada Res_2? Intenté usar el nombre de la tabla en su lugar, pero sigue siendo el mismo error.
Apreciaré si los expertos explican cómo se pueden aplicar los filtros sucesivos con Variables.
Gracias de antemano
Krishna
2 ACCEPTED SOLUTIONS
Syndicate_Admin
Administrator
Administrator

@kkanda

A su medida le faltaba un paréntesis de cierre en el primer Var.

Test Measure =
VAR Res_2 =
    FILTER (
        'M1 Notifications',
         (
            'M1 Notifications'[Created on]
                < ( TODAY () - 1825 )
                && 'M1 Notifications'[Created on]
                    > ( TODAY () - 365 )
        )
    )
VAR Res_1 =
    FILTER (
        Res_2,
         ( 'M1 Notifications'[Notification System Status] = "Outstanding notification"
            || 'M1 Notifications'[Notification System Status] = "Order assigned"
            || 'M1 Notifications'[Notification System Status] = "Notification in process" )
    )
RETURN
    IF ( COUNTROWS ( Res_1 ) <> BLANK (), COUNTROWS ( Res_1 ), UNICHAR ( ( 32 ) ) )

View solution in original post

Gracias por la corrección.

View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

@kkanda

A su medida le faltaba un paréntesis de cierre en el primer Var.

Test Measure =
VAR Res_2 =
    FILTER (
        'M1 Notifications',
         (
            'M1 Notifications'[Created on]
                < ( TODAY () - 1825 )
                && 'M1 Notifications'[Created on]
                    > ( TODAY () - 365 )
        )
    )
VAR Res_1 =
    FILTER (
        Res_2,
         ( 'M1 Notifications'[Notification System Status] = "Outstanding notification"
            || 'M1 Notifications'[Notification System Status] = "Order assigned"
            || 'M1 Notifications'[Notification System Status] = "Notification in process" )
    )
RETURN
    IF ( COUNTROWS ( Res_1 ) <> BLANK (), COUNTROWS ( Res_1 ), UNICHAR ( ( 32 ) ) )

Gracias por la corrección.

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.