Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I am trying to optimize the following into a single (or least) steps so that I can do the transform on the "target due date" and avoid creating a custom column altogether
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Discovered Date", type date}, {"Target Due Date", type date}}),
#"Replaced Errors" = Table.ReplaceErrorValues(#"Changed Type1", {{"Target Due Date", null}}),
#"Added Custom" = Table.AddColumn(#"Replaced Errors", "Due Date", each if [Target Due Date] = null
then Date.AddDays([Discovered Date],30)
else [Target Due Date], type date),
What would be the best way?
Thanks,
F
Solved! Go to Solution.
Hi @mfikram
Try this
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA3MAQiJR1kTqwOTM5I39AYKFehFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Discovered Date" = _t, #"Target Due Date" = _t]),
#"Format Text To Date" = Table.TransformColumns(Source,{{"Target Due Date", each try Date.FromText( _ ) otherwise null, type date }}),
#"Replaced Value" = Table.ReplaceValue(#"Format Text To Date",null, each Date.FromText( _[Discovered Date] ), Replacer.ReplaceValue,{"Target Due Date"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Discovered Date", type date}, {"Target Due Date", type date}})
in
#"Changed Type"
Hi @mfikram
Try this
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA3MAQiJR1kTqwOTM5I39AYKFehFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Discovered Date" = _t, #"Target Due Date" = _t]),
#"Format Text To Date" = Table.TransformColumns(Source,{{"Target Due Date", each try Date.FromText( _ ) otherwise null, type date }}),
#"Replaced Value" = Table.ReplaceValue(#"Format Text To Date",null, each Date.FromText( _[Discovered Date] ), Replacer.ReplaceValue,{"Target Due Date"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Discovered Date", type date}, {"Target Due Date", type date}})
in
#"Changed Type"
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
9 | |
7 | |
6 | |
6 |