Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
SJ25
Resolver I
Resolver I

Tabla de filtrado en función de la condición if

Hola a todos,

Tengo una tabla con datos de envíos y quiero sumar la cantidad de envíos para el día anterior. Así que si hoy es lunes, quiero filtrar la tabla para el viernes (hoy -3) pero si hoy es cualquier otro día, sólo quiero filtrar para el día anterior (Hoy-1).

Probé el DAX a continuación, pero no funcionó:

CALCULATE(SUM('Table1'[ShipmentAmount],FILTER('Table1',IF(WEEKDAY(TODAY(),2)-1, 'Table1'[ShipmentDate] á TODAY()-3,'Table1'[ShipmentDate]-TODAY()-1))))
Intenté mover la instrucción If en la fórmula, pero eso tampoco funcionó. Cualquier ayuda sería muy apreciada.
Gracias
2 ACCEPTED SOLUTIONS
nandukrishnavs
Super User
Super User

@SJ25

Prueba algo como esto

MeasureVal = 
VAR _weekday =
    WEEKDAY ( TODAY (), 2 )
VAR _x =
    IF ( _weekday = 1, 3, 1 )
VAR _result =
    CALCULATE (
        SUM ( 'Table1'[ShipmentAmount] ),
        FILTER ( 'Table1', Table1[ShipmentDate] - _x )
    )
RETURN
    _result



¿He respondido a tu pregunta? ¡Marca mi puesto como una solución!
Apreciar con un kudos
🙂


Regards,
Nandu Krishna

View solution in original post

SJ25
Resolver I
Resolver I

Gracias a todos por las respuestas rápidas. Pude hacerlo funcionar usando:

CALCULATE(SUM('Table1'[ShipmentAmount]),
FILTER('Table1',IF(WEEKDAY(TODAY(),2)-1, 'Table1'[ShipmentDate]-TODAY()-3, 'Table1'[ShipmentDate]-TODAY()-1)))

View solution in original post

4 REPLIES 4
SJ25
Resolver I
Resolver I

Gracias a todos por las respuestas rápidas. Pude hacerlo funcionar usando:

CALCULATE(SUM('Table1'[ShipmentAmount]),
FILTER('Table1',IF(WEEKDAY(TODAY(),2)-1, 'Table1'[ShipmentDate]-TODAY()-3, 'Table1'[ShipmentDate]-TODAY()-1)))
amitchandak
Super User
Super User

@SJ25 , consulte mi blog.

https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calenda...

Crear un rango en

Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])

y usar eso. He mostrado el uso de rango en [Work Date Cont],

Ahora -1 rango será ayer que es un día laborable

@SJ25 revisa este post

Me gustaría elogios si mi solución ayudara. 👉 Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos en https://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

nandukrishnavs
Super User
Super User

@SJ25

Prueba algo como esto

MeasureVal = 
VAR _weekday =
    WEEKDAY ( TODAY (), 2 )
VAR _x =
    IF ( _weekday = 1, 3, 1 )
VAR _result =
    CALCULATE (
        SUM ( 'Table1'[ShipmentAmount] ),
        FILTER ( 'Table1', Table1[ShipmentDate] - _x )
    )
RETURN
    _result



¿He respondido a tu pregunta? ¡Marca mi puesto como una solución!
Apreciar con un kudos
🙂


Regards,
Nandu Krishna

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors