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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Irbaz
Frequent Visitor

PowerBI add new columns on the basis of date

In the following table, I want to add 2 new columns with name Overdue  and due in 90 days) with values true or false. How Can I do that ?

 

Document TypeLatest Date
Certificate 13/1/2022
Certificate 21/31/2024
Layout Design7/1/2022
Statement 17/1/2022
Statement 23/1/2022
Processes Description10/1/2024
Flow Diagram10/1/2024
Floor Plan7/1/2022
Schedule 11/31/2024
Schedule 27/1/2022
List 17/1/2022
List 27/1/2022
Schedule A3/1/2022
Schedule Y3/1/2022
Schedule G3/1/2022
1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Put following formulas

For Overdue
= Date.From(DateTime.FixedLocalNow())>[Latest Date]

For Due in 90 days
= Date.IsInNextNDays([Latest Date],90)

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc89C8IwEAbgvxIyF9KkgrNYdOlQcJLSIcSzHrSNJCnivzeNEPq55sm9d29V0TMYh09U0gHhNKEZ40ykQtA6maPwyFkW9BC0kF89OJKDxab3epyO3pwf6qB3IXWHxHJhabQCa8GOqcrg26Eeo3nKJosvrf6QHGVjZLeF2pCyleuT1AseQ/vvOa8SSSyHCrQbFcLr6m9MOS17RbnvynUm9Q8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Document Type" = _t, #"Latest Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Document Type", type text}, {"Latest Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Overdue", each Date.From(DateTime.FixedLocalNow())>[Latest Date]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Due in 90 days", each Date.IsInNextNDays([Latest Date],90))
in
    #"Added Custom1"

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

Put following formulas

For Overdue
= Date.From(DateTime.FixedLocalNow())>[Latest Date]

For Due in 90 days
= Date.IsInNextNDays([Latest Date],90)

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc89C8IwEAbgvxIyF9KkgrNYdOlQcJLSIcSzHrSNJCnivzeNEPq55sm9d29V0TMYh09U0gHhNKEZ40ykQtA6maPwyFkW9BC0kF89OJKDxab3epyO3pwf6qB3IXWHxHJhabQCa8GOqcrg26Eeo3nKJosvrf6QHGVjZLeF2pCyleuT1AseQ/vvOa8SSSyHCrQbFcLr6m9MOS17RbnvynUm9Q8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Document Type" = _t, #"Latest Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Document Type", type text}, {"Latest Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Overdue", each Date.From(DateTime.FixedLocalNow())>[Latest Date]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Due in 90 days", each Date.IsInNextNDays([Latest Date],90))
in
    #"Added Custom1"

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.