Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin 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 All,
I have the following table in Power Query:
I am trying to create a custom column which satisfies the following criteria:
I've had a go at it here:
When I run the query I get a Custom Column with "Compliant" and "Non-Compliant" values along with error values for every "null" in [Completion Date], I suspect it's got something to do with the way I'm referring to today's date in the query.
Please let me know what you think and thank you in advance.
Solved! Go to Solution.
Hi @Anonymous ,
Add the custom column as below should work.
if [Completion Date] = null then if Date.AddDays([Inspection Date],[Response Time]) >= DateTime.Date(DateTime.LocalNow()) then "Compliant" else "Non-Compliant" else if [Completion Date] <= [Due Date] then "Compliant" else "Non-Compliant"
M code for your reference.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtW30DcyMLRQ0lEy0zeHMZFEjQ2UYnWIV2cC5CNkEWwTfWMDDCMNkcw0hDGRzTK0RJiFYGM3AsgGucvIEM0MZDeAzYCpMCNWBVXDKBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Inspection Date" = _t, #"Due Date" = _t, #"Completion Date" = _t, #"Response Time" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Inspection Date", type date}, {"Due Date", type date}, {"Completion Date", type date}, {"Response Time", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Completion Date] = null then if Date.AddDays([Inspection Date],[Response Time]) >= DateTime.Date(DateTime.LocalNow()) then "Compliant" else "Non-Compliant" else if [Completion Date] <= [Due Date] then "Compliant" else "Non-Compliant") in #"Added Custom"
Regards,
Frank
Hi @Anonymous ,
Add the custom column as below should work.
if [Completion Date] = null then if Date.AddDays([Inspection Date],[Response Time]) >= DateTime.Date(DateTime.LocalNow()) then "Compliant" else "Non-Compliant" else if [Completion Date] <= [Due Date] then "Compliant" else "Non-Compliant"
M code for your reference.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtW30DcyMLRQ0lEy0zeHMZFEjQ2UYnWIV2cC5CNkEWwTfWMDDCMNkcw0hDGRzTK0RJiFYGM3AsgGucvIEM0MZDeAzYCpMCNWBVXDKBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Inspection Date" = _t, #"Due Date" = _t, #"Completion Date" = _t, #"Response Time" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Inspection Date", type date}, {"Due Date", type date}, {"Completion Date", type date}, {"Response Time", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Completion Date] = null then if Date.AddDays([Inspection Date],[Response Time]) >= DateTime.Date(DateTime.LocalNow()) then "Compliant" else "Non-Compliant" else if [Completion Date] <= [Due Date] then "Compliant" else "Non-Compliant") in #"Added Custom"
Regards,
Frank
It works! Thank you for taking the time to help me!
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
59 | |
56 | |
38 | |
29 |
User | Count |
---|---|
82 | |
62 | |
45 | |
41 | |
40 |