Forum Discussion
if Function in Custom Column returns inconsistent result - what am I doing wrong ?
- Anonymous2 years ago
Hi Anonymous
Based on the sample data you have offered, you need to make sure that:
The data type of the taskid is whole number, and the minutes type should also be whole number, it should be like the following piture
Then you can try the following code in custom column.
General:
if [TaskId]=null and [Type] = 14 then [Minutes] else nullMeetings:
if [TaskId] = null and ([Type] = 1 or [Type] = 2 or [Type] =8 ) then [Minutes] else nullOutput
And you can refer to the following code in Advanced Editor in power query.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY5REgARCIavsuPZAxVyFuP+11i17DA8eCjl+/+qFANImNhYg64lGsWjUe0kAIEeRjUpAuQkptgi9HfBwWH/xh2P+Z5lhse/PGj0NtyPlKnqHpdFN7OsrKPsbm0UpOXOvu4O6g44LiRefHwD6ws=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TaskId = _t, Minutes = _t, Type = _t, #"Task Minutes" = _t, #"General Minutes" = _t, Admin = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"TaskId", Int64.Type}, {"Minutes", Int64.Type}, {"Type", Int64.Type}, {"Task Minutes", Int64.Type}, {"General Minutes", Int64.Type}, {"Admin", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "General", each if [TaskId]=null and [Type] = 14 then [Minutes] else null), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Meetings", each if [TaskId] = null and ([Type] = 1 or [Type] = 2 or [Type] = then [Minutes] else null), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Admin"}) in #"Removed Columns"Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous2 years ago
Great, that works fine, thank you for your help Yolo !
Hi Anonymous
Based on the sample data you have offered, you need to make sure that:
The data type of the taskid is whole number, and the minutes type should also be whole number, it should be like the following piture
Then you can try the following code in custom column.
General:
if [TaskId]=null and [Type] = 14 then [Minutes] else null
Meetings:
if [TaskId] = null and ([Type] = 1 or [Type] = 2 or [Type] =8 ) then [Minutes] else null
Output
And you can refer to the following code in Advanced Editor in power query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY5REgARCIavsuPZAxVyFuP+11i17DA8eCjl+/+qFANImNhYg64lGsWjUe0kAIEeRjUpAuQkptgi9HfBwWH/xh2P+Z5lhse/PGj0NtyPlKnqHpdFN7OsrKPsbm0UpOXOvu4O6g44LiRefHwD6ws=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TaskId = _t, Minutes = _t, Type = _t, #"Task Minutes" = _t, #"General Minutes" = _t, Admin = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"TaskId", Int64.Type}, {"Minutes", Int64.Type}, {"Type", Int64.Type}, {"Task Minutes", Int64.Type}, {"General Minutes", Int64.Type}, {"Admin", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "General", each if [TaskId]=null and [Type] = 14 then [Minutes] else null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Meetings", each if [TaskId] = null and ([Type] = 1 or [Type] = 2 or [Type] = then [Minutes] else null),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Admin"})
in
#"Removed Columns"
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous2 years agoNot applicable
Great, that works fine, thank you for your help Yolo !