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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

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
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Top Solution Authors
Top Kudoed Authors