Forum Discussion

Denpowerbi's avatar
Denpowerbi
Regular Visitor
6 years ago
Solved

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. Ec...
  • Anonymous's avatar
    Anonymous
    6 years ago

    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