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
Lesley1Storey
New Member

Adición de días laborables a fechas

Hola, tengo una tabla que muestra una fecha de creación para cuando se introducen facturas en nuestro sistema. Necesito agregar días laborables a esta fecha para obtener nuestra fecha de SLA. Tengo una mesa de fechas que tiene un índice de día de la semana incluido con los días 1-5 (sábado y domingo incluidos como día 5). Necesito añadir los días laborables a la fecha de creación. Las dos tablas se conectan por fecha de creación desde el archivo Facturas y Fechas de la tabla Fecha. Cualquier ayuda sería muy apreciada.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hola @Lesley1Storey ,

No sé si desea una columna calculada o una medida, pero puede hacer lo siguiente.

Cree una columna en la tabla de calendario

Workday = 
SWITCH (
    TRUE ();    
WEEKDAY('Calendar'[Date]) IN { 6 ; 7 }; FALSE (); 
    TRUE ()
)

Ahora agregue la siguiente medida a su modelo:

Forecasted End Date = 
----------------------------------------------------------
VAR relevantdate =
    SELECTEDVALUE(Invoices[Date]) --this can be replaced by TODAY()
VAR workdaysremain =
    15 --Can be adjusted to be another value
---------------------------------------------------------
/* create a virtual date table only for working days starting from
   the relevant date and only for the workdays remaining */
VAR workingdateTable =
    TOPN (
        workdaysremain;
        CALCULATETABLE (
            'Calendar';
            'Calendar'[Workday] = TRUE ();
            'Calendar'[Date] >= relevantdate
        )
    ) 
---------------------------------------------------------
/* find the maximum date in the virtual table, which will be
   the forecasted end date */
VAR futuredate =
    CALCULATE ( MAX ( 'Calendar'[Date] ); workingdateTable ) 
---------------------------------------------------------
RETURN
    futuredate

esto fue adaptado del siguiente post:

https://www.pbiusergroup.com/communities/community-home/digestviewer/viewthread?MessageKey=a5b04c5c-...


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hola @Lesley1Storey ,

No sé si desea una columna calculada o una medida, pero puede hacer lo siguiente.

Cree una columna en la tabla de calendario

Workday = 
SWITCH (
    TRUE ();    
WEEKDAY('Calendar'[Date]) IN { 6 ; 7 }; FALSE (); 
    TRUE ()
)

Ahora agregue la siguiente medida a su modelo:

Forecasted End Date = 
----------------------------------------------------------
VAR relevantdate =
    SELECTEDVALUE(Invoices[Date]) --this can be replaced by TODAY()
VAR workdaysremain =
    15 --Can be adjusted to be another value
---------------------------------------------------------
/* create a virtual date table only for working days starting from
   the relevant date and only for the workdays remaining */
VAR workingdateTable =
    TOPN (
        workdaysremain;
        CALCULATETABLE (
            'Calendar';
            'Calendar'[Workday] = TRUE ();
            'Calendar'[Date] >= relevantdate
        )
    ) 
---------------------------------------------------------
/* find the maximum date in the virtual table, which will be
   the forecasted end date */
VAR futuredate =
    CALCULATE ( MAX ( 'Calendar'[Date] ); workingdateTable ) 
---------------------------------------------------------
RETURN
    futuredate

esto fue adaptado del siguiente post:

https://www.pbiusergroup.com/communities/community-home/digestviewer/viewthread?MessageKey=a5b04c5c-...


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.