Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Buenas tardes,
Tengo una base de datos de solicitudes que se radican a diario y necesito tener la suma de los solicitudes que se radicaron el día anterior y el trasanterior de los días laborales, en mi modelo de datos ya tengo una tabla calendario vinculada con otra tabla de los días festivos (o no laborales) la cual relacione y cree una nueva columna llamada "TIPO DE DÍA" que me indica que para los días sabados, domingos o festivos me coloque "Día No Laboral" y para los que no, "Día Laboral".
Basado en esto logre calcular la fecha del ultimo día laboral de la siguiente manera = CALCULATE(MAX('BASE'[Fecha_Solicitud]) , Calendario[TIPO DE DÍA] = "Día Laboral")
Pero no he conseguido obtener el penultimo día laboral, teniendo en cuenta que para el reporte que se genera el día lunes, en la base de datos que se ejecuta hay solicitudes del día sabado y domingo. Pero yo necesito las solicitudes del día anterior y trasanterior de los días laborales, es decir las solitudes del día viernes (que seria el ultimo día laboral) y las solicitudes del día jueves (que seria el penultimo día laboral)
Les agradecieria mucho si me pueden colaborar, gracias.
Solved! Go to Solution.
Hi @felipevinasco ,
I create a sample to have a test in myside. In my sample, date is from 2023/01/01 to today (2023/02/21).
Holiday:
Calendar:
Calendar = ADDCOLUMNS(CALENDAR(DATE(2023,01,01),TODAY()),"Weekday",WEEKDAY([Date],2))
DayType column:
DAY_TYPE =
IF(OR('Calendar'[Weekday] IN {6,7},'Calendar'[Date] IN VALUES(Holiday[Holiday])),"Non-Working Day","Working Day")
You can try measure as below.
Last Working Day =
VAR _GENERATE_DAY =
TODAY ()
VAR _GENERATE_DAY_TYPE =
CALCULATE (
MAX ( 'Calendar'[DAY_TYPE] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _GENERATE_DAY )
)
VAR _RESULT1 =
CALCULATE (
MAX ( 'Calendar'[Date] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[DAY_TYPE] = "Working Day" )
)
VAR _RESULT2 =
CALCULATE (
MAX ( 'Calendar'[Date] ),
FILTER (
ALL ( 'Calendar' ),
AND ( 'Calendar'[DAY_TYPE] = "Working Day", 'Calendar'[Date] < _RESULT1 )
)
)
RETURN
IF ( _GENERATE_DAY_TYPE <> "Working Day", _RESULT1, _RESULT2 )
Penultimate Working Day =
CALCULATE (
MAX ( 'Calendar'[Date] ),
FILTER (
ALL ( 'Calendar' ),
AND (
'Calendar'[DAY_TYPE] = "Working Day",
'Calendar'[Date] < [Last Working Day]
)
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @felipevinasco ,
I create a sample to have a test in myside. In my sample, date is from 2023/01/01 to today (2023/02/21).
Holiday:
Calendar:
Calendar = ADDCOLUMNS(CALENDAR(DATE(2023,01,01),TODAY()),"Weekday",WEEKDAY([Date],2))
DayType column:
DAY_TYPE =
IF(OR('Calendar'[Weekday] IN {6,7},'Calendar'[Date] IN VALUES(Holiday[Holiday])),"Non-Working Day","Working Day")
You can try measure as below.
Last Working Day =
VAR _GENERATE_DAY =
TODAY ()
VAR _GENERATE_DAY_TYPE =
CALCULATE (
MAX ( 'Calendar'[DAY_TYPE] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _GENERATE_DAY )
)
VAR _RESULT1 =
CALCULATE (
MAX ( 'Calendar'[Date] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[DAY_TYPE] = "Working Day" )
)
VAR _RESULT2 =
CALCULATE (
MAX ( 'Calendar'[Date] ),
FILTER (
ALL ( 'Calendar' ),
AND ( 'Calendar'[DAY_TYPE] = "Working Day", 'Calendar'[Date] < _RESULT1 )
)
)
RETURN
IF ( _GENERATE_DAY_TYPE <> "Working Day", _RESULT1, _RESULT2 )
Penultimate Working Day =
CALCULATE (
MAX ( 'Calendar'[Date] ),
FILTER (
ALL ( 'Calendar' ),
AND (
'Calendar'[DAY_TYPE] = "Working Day",
'Calendar'[Date] < [Last Working Day]
)
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
20 | |
18 | |
18 | |
15 |
User | Count |
---|---|
37 | |
19 | |
19 | |
17 | |
11 |