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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors