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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Denpowerbi
Regular Visitor

New column with Calculated Date

Ciao a tutti, 
devo calcolare una nuova data ordine sapendo che
_se la data ordine è stata inserita> 16.00 devo aggiungere 1 giorno.
_se la data calcolata ricade in un giorno festivo (sab. Dom. Ecc) devo posticiparla al primo giorno lavorativo.
Ho inserito una tabella calendario con i soli giorni lavorativi, con la funzione "SE" riesco a posticipare in un giorno i dati calcolati MA non riesco in nessun modo a posticipare la data al primo giorno utile lavorativo
Sono bloccato su questo punto, spero che qualcuno mi possa aiutare
grazie in anticipo!

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @Denpowerbi,

I think you need to add conditions to if statement to check its weekday and hour. Please take a look at  following calculate column formula if it meets  your requirement:

NewDate = 
IF (
    HOUR ( [Datetime] ) >= 16,
    IF (
        WEEKDAY ( [Datetime], 2 ) >= 5,
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) + 7
            - WEEKDAY ( [Datetime], 2 ) + 1 ),
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) + 1 )
    ),
    IF (
        WEEKDAY ( [Datetime], 2 ) >= 5,
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) + 7
            - WEEKDAY ( [Datetime], 2 ) + 1 ),
        [Datetime]
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @Denpowerbi,

I think you need to add conditions to if statement to check its weekday and hour. Please take a look at  following calculate column formula if it meets  your requirement:

NewDate = 
IF (
    HOUR ( [Datetime] ) >= 16,
    IF (
        WEEKDAY ( [Datetime], 2 ) >= 5,
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) + 7
            - WEEKDAY ( [Datetime], 2 ) + 1 ),
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) + 1 )
    ),
    IF (
        WEEKDAY ( [Datetime], 2 ) >= 5,
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) + 7
            - WEEKDAY ( [Datetime], 2 ) + 1 ),
        [Datetime]
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you very much, I solved my problem with a small change to your suggestion.

NewDate
IF (
'OSC Sales Header :' [Now]> TIMEVALUE ("15:59:59");
IF (
WEEKDAY ([Date Order]; 2)> : 5;
DATE (YEAR([ORDER DATE]); MONTH ([Order Date]); DAY ([ORDER DATE]) : 7
- WEEKDAY ([Order Date]; 2) : 1);
DATE (YEAR ([Order Date]); MONTH ([Order Date]); DAY ([Order Date]) : 1)
);
"OSC Sales Header " [Order Date]
)

amitchandak
Super User
Super User

@Denpowerbi ,

for checking the time you can use

Try in new column something like this

if([date].time > time(16,0,0) ,[date]+1,[date])

 

do add subtract working day  see if my blog can help

https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calenda...

 

Grazie, per controllare il tempo ok.
Ho guardato il tuo blog, molto interessante ma non riesco ancora a gestire i dati +1 solo nei giorni di lavoro.

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.