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

DAX: ¿Cómo escribir "IF x then FILTER", simple??

Hola a todos

Sé que esto debería ser simple, pero no está funcionando para mí sin importar lo que intente. Necesito sumar la columna Total excluyendo EMP## 3039 por completo y excluyendo EMP## 1140 si la fecha es mayor que 5/31/21.

Se mostrará una suma total en un visual de tarjeta que se filtra por una segmentación de datos de mes y año en la página del informe.

EMP## FECHA TOTAL
1140 5/28/2021 8.93
1181 5/28/2021 7.68
1184 5/31/2021 6.58
3039 5/31/2021 8.12
1140 6/1/2021 9.12
1181 6/1/2021 4.67
1184 6/1/2021 5.45
3039 6/1/2021 8.1
1140 6/2/2021 6.38
1181 6/2/2021 4.75
1184 6/2/2021 5.88
3039 6/2/2021 7.77

Esta es la fórmula que probé, pero excluye 1140 incluso cuando la selección de la cortadora de fecha es anterior al 31/5/21.

Horas trabajadas =
var maxdate =MAX(Punch_Report[FECHA])
DEVOLUCIÓN
CALCULAR (
SUMA ( «Punch_Report»[TOTAL] ) , FILTER(Punch_Report,
Punch_Report[EMP##] <> 3039),
IF (maxdate>44347, Punch_Report[EMP##] <> 1140 ))

¡Gracias de antemano!

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

@b2wise

Prueba esto.

Hours Worked = 
CALCULATE(
    SUM ( 'Table'[Total] ),
    KEEPFILTERS ( NOT ( 'Table'[EMP##] = 3039 )),
    KEEPFILTERS ( NOT ( 'Table'[EMP##] = 1140 && 'Table'[Date] > DATE (2021,5,31) ) )
)

jdbuchanan71_0-1632086152124.png

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

1) No estoy seguro de por qué está usando"maxdate>44347" y no maxdate > Date(2021,5,31)

2) Vea si esto lo resuelve por usted (no había otra condición)

Hours Worked = 
VAR maxdate =
    MAX ( Punch_Report[DATE] )
RETURN
    CALCULATE (
        SUM ( 'Punch_Report'[TOTAL] ),
        FILTER (
            Punch_Report,
            Punch_Report[EMP##] <> 3039
                && IF (
                    Punch_Report[DATE] > DATE ( 2021, 5, 31 ),
                    Punch_Report[EMP##] <> 1140,
                    Punch_Report[EMP##]
                )
        )
    )

Syndicate_Admin
Administrator
Administrator

@b2wise

Prueba esto.

Hours Worked = 
CALCULATE(
    SUM ( 'Table'[Total] ),
    KEEPFILTERS ( NOT ( 'Table'[EMP##] = 3039 )),
    KEEPFILTERS ( NOT ( 'Table'[EMP##] = 1140 && 'Table'[Date] > DATE (2021,5,31) ) )
)

jdbuchanan71_0-1632086152124.png

@jdbuchanan71 @moizsherwani Gracias!! La segunda consulta DAX fue un poco más rápida, así que opté por esa.

Gracias de nuevo

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.