Forum Discussion
Replace date values before specific date or error value to Null
- 1 year ago
let
Source = Table.Combine({#"TOSS 데이터_공사목록 - Previous Backup Data",
#"TOSS 데이터_공사목록 - Current Weekly Data"}),DateTransformation = each
let temp = try Date.From(_)
in
if _ = null then null
else if temp[HasError] then null
else if temp[Value] < #date(2000, 1, 1) then null
else temp[Value],ColumnsToTransform = {"준공예정일자", "준공신고서제출일자", "준공신고서승인일자", "정산확인일자"},
TransformedTable = Table.TransformColumns(Source,
List.Transform(ColumnsToTransform, each {_, DateTransformation, type nullable date}))in
TransformedTable - 1 year ago
Hii Anonymous
The error you're seeing likely comes from some cells in the 준공예정일자 and other date columns containing unexpected data types (e.g., records instead of dates or text).
let
Source = Table.Combine({#"TOSS 데이터_공사목록 - Previous Backup Data", #"TOSS 데이터_공사목록 - Current Weekly Data"}),
// Define the transformation function with better error handling
DateTransformation = each try
if _ = null then null
else if Date.From(_) < #date(2000, 1, 1) then null
else Date.From(_)
otherwise null, // If an error occurs, set the value to null
// List of columns to transform
ColumnsToTransform = {"준공예정일자", "준공신고서제출일자", "준공신고서승인일자", "정산확인일자"},
// Apply the transformation to multiple columns
TransformedTable = Table.TransformColumns(Source, List.Transform(ColumnsToTransform, each {_, DateTransformation, type nullable date}))
in
TransformedTableIf this helps, I would appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!
let
Source = Table.Combine({#"TOSS 데이터_공사목록 - Previous Backup Data", #"TOSS 데이터_공사목록 - Current Weekly Data"}),
DateTransformation = each if _ = null then null
else if try Date.From(_) = null then null
else if Date.From(_) < #date(2000, 1, 1) then null
else Date.From(_),
ColumnsToTransform = {"준공예정일자", "준공신고서제출일자", "준공신고서승인일자", "정산확인일자"},
TransformedTable = Table.TransformColumns(Source, List.Transform(ColumnsToTransform, each {_, DateTransformation, type nullable date}))
in
TransformedTable
Still not working well
The error you're seeing likely comes from some cells in the 준공예정일자 and other date columns containing unexpected data types (e.g., records instead of dates or text).
let
Source = Table.Combine({#"TOSS 데이터_공사목록 - Previous Backup Data", #"TOSS 데이터_공사목록 - Current Weekly Data"}),
// Define the transformation function with better error handling
DateTransformation = each try
if _ = null then null
else if Date.From(_) < #date(2000, 1, 1) then null
else Date.From(_)
otherwise null, // If an error occurs, set the value to null
// List of columns to transform
ColumnsToTransform = {"준공예정일자", "준공신고서제출일자", "준공신고서승인일자", "정산확인일자"},
// Apply the transformation to multiple columns
TransformedTable = Table.TransformColumns(Source, List.Transform(ColumnsToTransform, each {_, DateTransformation, type nullable date}))
in
TransformedTable
If this helps, I would appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!