Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
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?
Solved! Go to Solution.
Hi @mburkett ,
Suppose we have:
Please follow these steps:
1. Duplicated [Date] Column:
2. Change [Date - Copy]'s Type from [Date] to [Date/Time]
3. Add a custom column:
if [#"Date - Copy"] > DateTime.LocalNow()
then Date.AddYears([Date],-1)
else [Date]
4. Remove and rename columns.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc65DQAgDAPAXaiRwAnvLCj7r4EokOzyujsnoaBYNU+RH4zhjMbojMGYjMXYDFSRHCAJyALSwH/EBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Date", "Date - Copy"),
#"Changed Type1" = Table.TransformColumnTypes(#"Duplicated Column",{{"Date - Copy", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each if [#"Date - Copy"] > DateTime.LocalNow()
then Date.AddYears([Date],-1)
else [Date]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Date", "Date - Copy"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Date"}})
in
#"Renamed Columns"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @mburkett ,
Suppose we have:
Please follow these steps:
1. Duplicated [Date] Column:
2. Change [Date - Copy]'s Type from [Date] to [Date/Time]
3. Add a custom column:
if [#"Date - Copy"] > DateTime.LocalNow()
then Date.AddYears([Date],-1)
else [Date]
4. Remove and rename columns.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc65DQAgDAPAXaiRwAnvLCj7r4EokOzyujsnoaBYNU+RH4zhjMbojMGYjMXYDFSRHCAJyALSwH/EBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Date", "Date - Copy"),
#"Changed Type1" = Table.TransformColumnTypes(#"Duplicated Column",{{"Date - Copy", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each if [#"Date - Copy"] > DateTime.LocalNow()
then Date.AddYears([Date],-1)
else [Date]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Date", "Date - Copy"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Date"}})
in
#"Renamed Columns"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
@mburkett
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 13 | |
| 11 | |
| 11 | |
| 8 | |
| 6 |