Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Queridos campeones:
He estado tratando de crear un horario y días de trabajo comerciales en modo de consulta directa. Pero no puedo usar ciertas funciones como SUMX y LOOKUP Value. Es cualquier sintaxis alternativa que podamos usar. Esta es la siguiente medida que estoy utilizando.
Gracias de antemano.
@Rockz , Intente usar belowmeasure
Horas de trabajo entre fechas =
VAR startDate = DATEVALUE('Issue Query'[DateCreatedon])
VAR startTime = TIMEVALUE('Consulta de problema'[DateCreatedon])
VAR endDate = DATEVALUE('Issue Query'[DateClosedOn])
VAR endTime = TIMEVALUE('Consulta de problema'[DateClosedOn])
VAR firstFullDay = FechaDeinicio + 1
VAR lastFullDay = endDate - 1
VAR inBetweenWorkingHours =
SI(
firstFullDay > lastFullDay,
0,
CALCULAR(
SUM(WorkingHoursTable[WorkingHours]),
FILTRO(
Tabla de horas de trabajo,
WorkingHoursTable[Date] >= firstFullDay &&
WorkingHoursTable[Date] <= lastFullDay &&
WorkingHoursTable[IsWorkingDay] = TRUE()
)
)
)
VAR firstDayStart = CALCULAR(
MAX(WorkingHoursTable[StartTime]),
FILTRO(
Tabla de horas de trabajo,
WorkingHoursTable[WeekDay] = WEEKDAY(startDate, 2)
)
)
VAR firstDayEnd = CALCULAR(
MAX(WorkingHoursTable[EndTime]),
FILTRO(
Tabla de horas de trabajo,
WorkingHoursTable[WeekDay] = WEEKDAY(startDate, 2)
)
)
VAR lastDayStart = CALCULAR(
MAX(WorkingHoursTable[StartTime]),
FILTRO(
Tabla de horas de trabajo,
WorkingHoursTable[WeekDay] = WEEKDAY(endDate, 2)
)
)
VAR lastDayEnd = CALCULAR(
MAX(WorkingHoursTable[EndTime]),
FILTRO(
Tabla de horas de trabajo,
WorkingHoursTable[WeekDay] = WEEKDAY(endDate, 2)
)
)
VAR effectiveStartTime = IF(startTime < firstDayStart, firstDayStart, startTime)
VAR effectiveEndTime = IF(endTime > lastDayEnd, lastDayEnd, endTime)
DEVOLUCIÓN
SI(
FechaInicio= FechaFinal,
24 * IF(effectiveEndTime > effectiveStartTime, effectiveEndTime - effectiveStartTime, 0),
VAR primerDíaHoraLaboral =
24 *
SI(
startTime > firstDayEnd,
0,
firstDayEnd - effectiveStartTime
)
VAR últimaHoraTrabajadora =
24 *
SI(
endTime < lastDayStart,
0,
effectiveEndTime - lastDayStart
)
RETURN firstDayWorkingHour + lastDayWorkingHour + inBetweenWorkingHours
)
Caro
Gracias por su rápida respuesta.
Pero mientras uso esto, recibo este error
Las operaciones de comparación de DAX no admiten la comparación de valores de tipo True/False con valores de tipo Integer. Considere la posibilidad de utilizar la función VALUE o FORMAT para convertir uno de los valores.
y necesito usar la condición de verdadero / falso para la tabla de horas de trabajo.
Esta es la medida que estoy utilizando para la tabla de horas de trabajo.
Gracias.
Hola @Rockz ,
Me gustaría agradecer el valioso aporte proporcionado por el @bhanu_gautam . Sus ideas iniciales fueron fundamentales para guiar mi enfoque. Sin embargo, me di cuenta de que se necesitaban más detalles para comprender completamente el problema.
El problema puede estar aquí, su campo [IsWorkingDay] es 1 o 0.
VAR inBetweenWorkingHours =
IF (
firstFullDay > lastFullDay,
0,
CALCULATE (
SUM ( WorkingHoursTable[WorkingHours] ),
FILTER (
WorkingHoursTable,
WorkingHoursTable[Date] >= firstFullDay
&& WorkingHoursTable[Date] <= lastFullDay
&& WorkingHoursTable[IsWorkingDay] = TRUE ()
)
)
)
Así que puedes intentar cambiar aquí a esto.
VAR inBetweenWorkingHours =
IF (
firstFullDay > lastFullDay,
0,
CALCULATE (
SUM ( WorkingHoursTable[WorkingHours] ),
FILTER (
WorkingHoursTable,
WorkingHoursTable[Date] >= firstFullDay
&& WorkingHoursTable[Date] <= lastFullDay
&& WorkingHoursTable[IsWorkingDay] = 1
)
)
)
Si su período actual no se refiere a esto, aclare en una respuesta de seguimiento.
Saludos
Clara Gong
Si esta publicación ayuda, considere Acéptalo como la solución para ayudar a los demás miembros a encontrarlo más rápidamente.
Caro
¡Recibo este error de nuevo!
La función 'CALCULATE' no está permitida como parte de las expresiones DAX de columna calculadas en los modelos de DirectQuery.
Hola @Rockz ,
Intente usar la expresión como MEASURE en lugar de una columna calculada.
Saludos
Clara Gong
Si esta publicación ayuda, considere Acéptalo como la solución para ayudar a los demás miembros a encontrarlo más rápidamente.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.