cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

Dax a una suma acumulada

Hola a todos

Estoy luchando aquí...

Estoy tratando de hacer un gráfico con una suma acumulada de horas reportadas durante el período de contratos para cada contrato.

Las horas notificadas están en la tabla Timeworked y el período del contrato está en TblContracts, los campos TblContracts[Contract Start Date] y TblContracts[Contract End Date] no tienen ninguna relación.

Mi modelo de datos:

brunoemr_1-1612348700362.png

brunoemr_0-1612348687627.png

Estoy usando el Dax a continuación, devuelve las horas notificadas en el período, pero no devuelve los valores acumulativos.

Cumulative TimeWorked =
var starts_ = MAX(TblContracts[Contract Start Date])
var ends = MAX(TblContracts[Contract End Date])
return
CALCULATE(
SUM(Timeworked[Total_time_in_hours])
,FILTER( Date_dim,
Date_dim[full_date] >= starts_ &&
Date_dim[full_date] <= ends
)
,CROSSFILTER (Timeworked[date_dim_id],Date_dim[date_dim_id], BOTH )
,CROSSFILTER ( Timeworked[task_dim_id], Overview[project_task_dim_id], BOTH)
)

¿Cómo puedo lograr los valores acumulados?

Gracias de antemano.

Brunor.

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Hola

He encontrado una solución.

Dax final:

Cumulative TimeWorked = 
VAR minDate =
    MIN ( TblContracts[Contract Start Date] )
VAR maxDate =
    MAX ( TblContracts[Contract End Date] )
VAR totalHours =
    CALCULATE (
        SUM ( Timeworked[Total_time_in_hours] ),
        FILTER (
                ALL ( Date_dim ),
                Date_dim[date] >= minDate
                && Date_dim[date] <= MAX ( Date_dim[date] )
                && ( MAX ( Date_dim[date] ) <= TODAY() && MAX ( Date_dim[date] ) <= maxDate)
        )
        ,   CROSSFILTER ( TblContracts[SNOW reporting ticket - billable ], Overview[project_task_number], BOTH )
        ,   CROSSFILTER ( Timeworked[task_dim_id], Overview[project_task_dim_id], Both)            
        ,   CROSSFILTER ( Timeworked[date_dim_id], Date_dim[date_dim_id], BOTH )
    )

return totalHours

Gracias

Bruno

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Hola

He encontrado una solución.

Dax final:

Cumulative TimeWorked = 
VAR minDate =
    MIN ( TblContracts[Contract Start Date] )
VAR maxDate =
    MAX ( TblContracts[Contract End Date] )
VAR totalHours =
    CALCULATE (
        SUM ( Timeworked[Total_time_in_hours] ),
        FILTER (
                ALL ( Date_dim ),
                Date_dim[date] >= minDate
                && Date_dim[date] <= MAX ( Date_dim[date] )
                && ( MAX ( Date_dim[date] ) <= TODAY() && MAX ( Date_dim[date] ) <= maxDate)
        )
        ,   CROSSFILTER ( TblContracts[SNOW reporting ticket - billable ], Overview[project_task_number], BOTH )
        ,   CROSSFILTER ( Timeworked[task_dim_id], Overview[project_task_dim_id], Both)            
        ,   CROSSFILTER ( Timeworked[date_dim_id], Date_dim[date_dim_id], BOTH )
    )

return totalHours

Gracias

Bruno

View solution in original post

Syndicate_Admin
Administrator
Administrator

@brunoemr , ¿Puede compartir datos de ejemplo y salida de ejemplo en formato de tabla? O una muestra de pbix después de eliminar datos confidenciales.

si este blog puede ayudar

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Por supuesto, aquí hay una muestra:

brunoemr_0-1612357457730.png

brunoemr_1-1612357475832.png

brunoemr_0-1612361768605.png

Mi Datedim tiene todas las fechas de 2013 a 2030, necesito evitar fechas futuras.

Gracias

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors