Forum Discussion
Custom Column Help
- Anonymous2 years ago
Hi beerock ,
In addition to the PwerQueryKees‘s method, you can also try adding a custom column:
First add an Index column:Then use this M code to add a custom column:
let currentUser = [User], currentDnis = [#"DNIS(Dialed Number Identification Service)"], currentVoiceMailNo = [VoiceMail] = "No", currentIndex = [Index] in if currentVoiceMailNo then if Table.RowCount( Table.SelectRows(#"Added Index", each ([#"ANI(Automatic Number Identification)"] = currentDnis and [User] = currentUser and [Index] < currentIndex)) ) > 0 then 1 else 0 else 0And the final output is as below:
Here is the whole M code in the Advanced Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFMIzs0syVDSUfLMS8ovzUsBsgyNjIGkqakpkIxMLVaK1cGp1NjEFK7ULx+fSjNzC7wq/UtLYEohiiCuACmNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, #"Call Direction" = _t, #"ANI(Automatic Number Identification)" = _t, #"DNIS(Dialed Number Identification Service)" = _t, VoiceMail = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ANI(Automatic Number Identification)", Int64.Type}, {"DNIS(Dialed Number Identification Service)", Int64.Type}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type), AddedCustom = Table.AddColumn(#"Added Index", "Custom Column", each let currentUser = [User], currentDnis = [#"DNIS(Dialed Number Identification Service)"], currentVoiceMailNo = [VoiceMail] = "No", currentIndex = [Index] in if currentVoiceMailNo then if Table.RowCount( Table.SelectRows(#"Added Index", each ([#"ANI(Automatic Number Identification)"] = currentDnis and [User] = currentUser and [Index] < currentIndex)) ) > 0 then 1 else 0 else 0) in AddedCustom
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - 2 years ago
Hi beerock, another solution:
Output
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFMIzs0syVDSUfLMS8ovzUsBsgyNjIGkqakpkIxMLVaK1cGp1NjEFK7ULx+fSjNzC7wq/UtLYEohiiCuACmNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, #"Call Direction" = _t, #"ANI(Automatic Number Identification)" = _t, #"DNIS(Dialed Number Identification Service)" = _t, VoiceMail = _t]), AddedIndexHelper = Table.AddIndexColumn(Source, "IndexHelper", 0, 1, Int64.Type), Ad_VoiceMailReturned = Table.AddColumn(AddedIndexHelper, "VoiceMailReturned", each [ a = Table.SelectRows(Table.Buffer(AddedIndexHelper), (x)=> x[Call Direction] = "Outbound" and x[#"DNIS(Dialed Number Identification Service)"] = [#"ANI(Automatic Number Identification)"] and x[IndexHelper] > [IndexHelper] and x[User] = [User]), b = if [VoiceMail] = "Yes" and not Table.IsEmpty(a) then "Yes" else "No" ][b], type text ), RemovedColumns = Table.RemoveColumns(Ad_VoiceMailReturned,{"IndexHelper"}) in RemovedColumns
Would merging the table with itself matching the outbound number with the inbound number work? You can the use any table function on the merge result column to add a custom column. Table.IsEmpty could work for you....
- beerock2 years agoNew Member
Thanks! This worked pretty well.... the only issue Table.IsEmpty() gets me close but because the merged table column is returning multiple results due to the fact that other agents can and do call the same number.