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

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.

Reply
Syndicate_Admin
Administrator
Administrator

Distribuir las horas de presupuesto restantes entre los días laborables entre el proyecto de fecha de inicio y de finalización

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:

proyectofecha de iniciofecha finalTotal de horas presupuestadas
A1-8-202113-8-202140
B9-8-202113-8-202140

Tabla de horas

proyecto

fechahoras
A2-8-20212
A2-8-20211
A3-8-20211

Tabla de fechas

fechajornada laboral
1-8-2021no
2-8-2021
3-8-2021
4-8-2021
5-8-2021
6-8-2021
7-8-2021no
8-8-2021no
9-8-2021
10-8-2021
11-8-2021
12-8-2021
13-8-2021

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

fechahoras
3-8-20214
4-8-20214
5-8-20214
6-8-20214
9-8-202112
10-8-202112
11-8-202112
12-8-202112
13-8-202112
1 ACCEPTED 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

vxiaotang_1-1628235398307.png

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.

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

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:

vxiaotang_0-1628143559689.png

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.

Hola @v-xiaotang

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

vxiaotang_1-1628235398307.png

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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