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.
Hola a todos
Quiero tener una medida que me dé el presupuesto restante por proyecto distribuido uniformemente durante los días hábiles desde hoy hasta la fecha límite del proyecto. Si un proyecto aún no ha comenzado, la medida debe darme las horas presupuestadas distribuidas uniformemente a lo largo de los días laborables entre [fecha de inicio] y [fecha de finalización]
Mis datos se ven así:
Tabla de proyectos:
proyecto | fecha de inicio | fecha final | Total de horas presupuestadas |
A | 1-8-2021 | 13-8-2021 | 40 |
B | 9-8-2021 | 13-8-2021 | 40 |
Tabla de horas
proyecto | fecha | horas |
A | 2-8-2021 | 2 |
A | 2-8-2021 | 1 |
A | 3-8-2021 | 1 |
Tabla de fechas
fecha | jornada laboral |
1-8-2021 | no |
2-8-2021 | Sí |
3-8-2021 | Sí |
4-8-2021 | Sí |
5-8-2021 | Sí |
6-8-2021 | Sí |
7-8-2021 | no |
8-8-2021 | no |
9-8-2021 | Sí |
10-8-2021 | Sí |
11-8-2021 | Sí |
12-8-2021 | Sí |
13-8-2021 | Sí |
Mi resultado deseado se ve así en base a que hoy es 3-8-2021:
Proyecto A (40 horas - 4 horas) / (días laborables restantes 9)= 4 horas por día
Proyecto B 40 horas/ 5 días laborables = 8 horas por día
Tabla de resultados
fecha | horas |
3-8-2021 | 4 |
4-8-2021 | 4 |
5-8-2021 | 4 |
6-8-2021 | 4 |
9-8-2021 | 12 |
10-8-2021 | 12 |
11-8-2021 | 12 |
12-8-2021 | 12 |
13-8-2021 | 12 |
Solved! Go to Solution.
No @BobKoenen
Pruebe esto
test1 =
CALCULATE (
SUM ( Projecttable[Total budgetted hours] ) - SUM ( 'Hours table'[Hours] ),
GROUPBY ( Projecttable, Projecttable[Project] )
)
test2 =
[test1]
/ MINX (
{
COUNTROWS (
FILTER (
ALL ( 'Date table' ),
'Date table'[date] >= MAX ( Projecttable[Start date] )
&& 'Date table'[date] <= MAX ( Projecttable[end date] )
&& 'Date table'[workingday] = "Yes"
)
),
COUNTROWS (
FILTER (
ALL ( 'Date table' ),
'Date table'[date] >= DATE ( 2021, 8, 3 )// you can replace DATE ( 2021, 8, 3 ) with Today() later.
&& 'Date table'[date] <= MAX ( Projecttable[end date] )
&& 'Date table'[workingday] = "Yes"
)
)
},
[Value]
)
test3 =
VAR _currentDateA =
CALCULATE ( MAX ( 'Hours table'[date] ), ALL ( 'Hours table' ) )
RETURN
IF (
MIN ( 'Date table'[workingday] ) <> "Yes"
|| MIN ( 'Date table'[date] ) < _currentDateA,
BLANK (),
SUMX (
FILTER (
ALLEXCEPT ( Projecttable, Projecttable[Project] ),
Projecttable[Start date] <= MAX ( 'Date table'[date] )
&& MAX ( 'Date table'[date] ) <= Projecttable[end date]
),
[test2]
)
)
resultado
Saludos
equipo de apoyo a la comunidad _Tang
Si este post ayuda,por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
No @BobKoenen
Utilice esta medida
Measure =
var _totalHourA=CALCULATE(MIN(Projecttable[Total budgetted hours]),Projecttable[Project]="A")
var _totalHourB=CALCULATE(MIN(Projecttable[Total budgetted hours]),Projecttable[Project]="B")
var _currentDateA=CALCULATE(MAX('Hours table'[date]),ALL('Hours table'))// get current date 2021/8/3
var _startdate=CALCULATE(MIN(Projecttable[Start date]),Projecttable[Project]="A")//get 2 date range, _startdate to _middate, _middate to _enddate
var _middate=CALCULATE(MIN(Projecttable[Start date]),Projecttable[Project]="B")//
var _enddate=CALCULATE(MIN(Projecttable[end date]),Projecttable[Project]="B")//
var _DaysRemainingA=CALCULATE(COUNTROWS('Date table'),FILTER(ALL('Date table'),'Date table'[workingday]="Yes"&&'Date table'[date]>=_currentDateA))// get remaining working days 9 of A
var _DaysRemainingB=CALCULATE(COUNTROWS('Date table'),FILTER(ALL('Date table'),'Date table'[workingday]="Yes"&&'Date table'[date]>=_middate&&'Date table'[date]<=_enddate))// get working days 9 of B
var _sumHourA=SUMX('Hours table','Hours table'[Hours])//get 4 hours of A
var _evenHour1=DIVIDE((_totalHourA-_sumHourA),_DaysRemainingA) // get (40-4)/9
var _evenHour2=DIVIDE(_totalHourB,_DaysRemainingB) // get 40/5
return IF(MIN('Date table'[workingday])<>"Yes"||MIN('Date table'[date])<_currentDateA,BLANK(),IF(MIN('Date table'[date])<_middate,_evenHour1,_evenHour2+_evenHour1))
resultado:
Consulte el archivo de ejemplo adjunto a continuación.
Saludos
equipo de apoyo a la comunidad _Tang
Si este post ayuda,por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Así que muchas gracias esto parece una fórmula realmente eloborada. Solo en realidad hay más de 100 proyectos y se agregan otros nuevos cada mes. ¿Es posible editar la fórmula para que sea dinámica, por lo que no necesitaré agregar nuevas variables cada vez que se agregue un nuevo proyecto?
No @BobKoenen
Pruebe esto
test1 =
CALCULATE (
SUM ( Projecttable[Total budgetted hours] ) - SUM ( 'Hours table'[Hours] ),
GROUPBY ( Projecttable, Projecttable[Project] )
)
test2 =
[test1]
/ MINX (
{
COUNTROWS (
FILTER (
ALL ( 'Date table' ),
'Date table'[date] >= MAX ( Projecttable[Start date] )
&& 'Date table'[date] <= MAX ( Projecttable[end date] )
&& 'Date table'[workingday] = "Yes"
)
),
COUNTROWS (
FILTER (
ALL ( 'Date table' ),
'Date table'[date] >= DATE ( 2021, 8, 3 )// you can replace DATE ( 2021, 8, 3 ) with Today() later.
&& 'Date table'[date] <= MAX ( Projecttable[end date] )
&& 'Date table'[workingday] = "Yes"
)
)
},
[Value]
)
test3 =
VAR _currentDateA =
CALCULATE ( MAX ( 'Hours table'[date] ), ALL ( 'Hours table' ) )
RETURN
IF (
MIN ( 'Date table'[workingday] ) <> "Yes"
|| MIN ( 'Date table'[date] ) < _currentDateA,
BLANK (),
SUMX (
FILTER (
ALLEXCEPT ( Projecttable, Projecttable[Project] ),
Projecttable[Start date] <= MAX ( 'Date table'[date] )
&& MAX ( 'Date table'[date] ) <= Projecttable[end date]
),
[test2]
)
)
resultado
Saludos
equipo de apoyo a la comunidad _Tang
Si este post ayuda,por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
No @BobKoenen
🤣100+ proyectos? en este caso, sugiero que mantenga su modelo lo más conciso posible. Combinar tablas con contenido similar. o será difícil mantener el modelo.
en los datos de ejemplo, hay 3 tablas: Projecttable, Tabla de horas, Tabla de fechas. Está bien.
Mientras continúe manteniendo esta estructura en la etapa posterior, la medida que escribí es suficiente. ( además, no he pensado en una manera de simplificarlo todavía.. 😂)
Saludos
equipo de apoyo a la comunidad _Tang
Si este post ayuda,por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |