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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Revised date with condition

I want to revise date against system date/time column as per mentioned the condition in below table.

 

System DateTimeConditionRevised Date
11-08-202218:30If before 18:30 the revised date should be next day12-08-2022
11-08-202218:30If after 18:30 the revised date should be day after day13-08-2022
11-08-202218:30If before 18:30 and next day is holiday then revised date should be day after day13-08-2022
11-08-202218:30If after 18:30 and next day is holiday then revised date should be day after 2 days14-08-2022
1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Create a list named Holidays where you store the list of Holidays and use below formula in a custom column

 

= Date.AddDays([System Date],1+Number.From([Time]>=#time(18,30,0))+Number.From(List.Contains(Holidays,[System Date])))

 

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1sNA1NFTSUTK0sDKyVIrVwRQ2NkAVNsWu2hShOhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"System Date" = _t, Time = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"System Date", type date}, {"Time", type time}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.AddDays([System Date],1+Number.From([Time]>=#time(18,30,0))+Number.From(List.Contains(Holidays,[System Date]))), type date)
in
    #"Added Custom"

 

Test Code for Holiday list (Give it name Holidays)

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstA3NNU3MjAyUorVAfGMDaG8WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Holidays = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Holidays", type date}}),
    Holidays = #"Changed Type"[Holidays]
in
    Holidays

 

 

View solution in original post

1 REPLY 1
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Create a list named Holidays where you store the list of Holidays and use below formula in a custom column

 

= Date.AddDays([System Date],1+Number.From([Time]>=#time(18,30,0))+Number.From(List.Contains(Holidays,[System Date])))

 

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1sNA1NFTSUTK0sDKyVIrVwRQ2NkAVNsWu2hShOhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"System Date" = _t, Time = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"System Date", type date}, {"Time", type time}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.AddDays([System Date],1+Number.From([Time]>=#time(18,30,0))+Number.From(List.Contains(Holidays,[System Date]))), type date)
in
    #"Added Custom"

 

Test Code for Holiday list (Give it name Holidays)

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstA3NNU3MjAyUorVAfGMDaG8WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Holidays = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Holidays", type date}}),
    Holidays = #"Changed Type"[Holidays]
in
    Holidays

 

 

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.