March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
I have the following mixed column containing status and date formatted as text. The date is entered when complete i.e. status is complete.
I would like 2 additional columns, 1 to assign a status (In Work, Pending, Complete) and another to extract the date.
Can anyone help? DATEVALUE doesn't seem to play.
Solved! Go to Solution.
Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxTCM8vylaK1YlWCkjNS8nMSwezDUz1Dcz1jQyMDCFcE31DYwQXWZehgb6hIUjKQCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"PIA Form" = _t]),
#"Added Custom" = Table.AddColumn(Source, "Status", each if Text.Contains([PIA Form], "/") then "Complete" else [PIA Form], type text),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "CompletionDate", each if [Status] = "Complete" then Date.From([PIA Form]) else null, type date)
in
#"Added Custom1"
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Check the example pbix for detail:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ30jcyMDJQitWJVvLMUwjPL8oGswNS81Iy89LBbCN9E6AiQ0swx0TfGKHDUN8QxDFUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column = _t]),
#"Duplicated Column" = Table.DuplicateColumn(Source, "Column", "Column - Copy"),
#"Changed Type" = Table.TransformColumnTypes(#"Duplicated Column",{{"Column - Copy", type date}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column - Copy", "Date"}}),
#"Replaced Errors" = Table.ReplaceErrorValues(#"Renamed Columns", {{"Date", null}}),
#"Added Conditional Column" = Table.AddColumn(#"Replaced Errors", "Status", each if [Date] = null then [Column] else null)
in
#"Added Conditional Column"
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxTCM8vylaK1YlWCkjNS8nMSwezDUz1Dcz1jQyMDCFcE31DYwQXWZehgb6hIUjKQCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"PIA Form" = _t]),
#"Added Custom" = Table.AddColumn(Source, "Status", each if Text.Contains([PIA Form], "/") then "Complete" else [PIA Form], type text),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "CompletionDate", each if [Status] = "Complete" then Date.From([PIA Form]) else null, type date)
in
#"Added Custom1"
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Do you want dates down the whole column? I'm having difficulty envisioning what your final table should look like.
--Nate
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
16 | |
13 | |
12 | |
9 |
User | Count |
---|---|
35 | |
31 | |
20 | |
19 | |
17 |