Forum

Date Transformation
 
Notifications
Clear all

Date Transformation

3 Posts
3 Users
0 Reactions
59 Views
(@michaelburkettgmail-com)
Posts: 1
New Member
Topic starter
 

I am pulling in a table from the web with only the day and month. Power query is guessing the date and setting everything to 2023. Is there a way to tell it to change to 2022 if the date is greater than today's date?

 
Posted : 06/01/2023 1:13 pm
Alan Sidman
(@alansidman)
Posts: 222
Member Moderator
 

Would be very helpful if you attached (uploaded) a sample file with 8-10 records showing what your file looks like when it has been downloaded from the Web.

 
Posted : 06/01/2023 8:27 pm
Riny van Eekelen
(@riny)
Posts: 1186
Member Moderator
 

I created a small example in the attached file, where the following code adds a column with corrected dates for dates after today.

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Corrected Date", each if Date.IsInYearToDate([Date]) then [Date] else Date.AddYears ([Date], -1))
in
#"Added Custom"

 
Posted : 07/01/2023 7:33 am
Share: