Power Query Nested If Function/Conditional Column Help

Anonymous
2025-01-09T17:55:47+00:00

Hello,I am doing some work in Power Query and would like to create either a column that will tell me the last contact number and it's associated status. The action item can be resolved prior to the final (6th) status, and I am having issues creating a conditional column with PQ that will 'read back' from 6th contact status to find the contact that is not in a null status (aka not attempted), and then pull that filled status and its respective contact number.I am unfamiliar with coding in M/Dax so any assistance would be appreciated! I have attached an example sample file. Thank you!

https://www.dropbox.com/scl/fi/4f0uyzsvpwsuz5oqrnb7d/PowerQuery-Contact-Sample-File.xlsx?rlkey=5us1h2cwomhldd6obz584gv7d&st=zmn2xgta&dl=0

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Andreas Killer 144K Reputation points Volunteer Moderator
    2025-01-10T05:59:41+00:00

    I would do it this way.

    Image

    Andreas.

    // Table1
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"1st Contact Date", type date}, {"2nd Contact Date", type date}, {"3rd Contact Date", type date}, {"4th Contact Date", type date}, {"5th Contact Date", type date}, {"6th Contact Date", type date}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Last", each Record.FromList(List.LastN(List.RemoveNulls(Record.ToList(_)),2), {"Last Date", "Last Status"})),
        #"Expanded {0}" = Table.ExpandRecordColumn(#"Added Custom", "Last", {"Last Date", "Last Status"}, {"Last Date", "Last Status"})
    in
        #"Expanded {0}"
    
    4 people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2025-01-15T12:42:14+00:00

    Hi Austin

    I'm writing a follow up this thread, as we haven’t received any news from you in a few days, may we know have you checked the replies given by our colleagues?

    Feel free to post back if you need further assistance.

    Regards

    Jeovany

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Ashish Mathur 101K Reputation points Volunteer Moderator
    2025-01-09T23:28:34+00:00

    Hi,

    This M code works

    let

    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], 
    
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"1st Contact Date", type datetime}, {"1st Contact Status", type text}, {"2nd Contact Date", type datetime}, {"2nd Contact Status", type text}, {"3rd Contact Date", type datetime}, {"3rd Contact Status", type text}, {"4th Contact Date", type datetime}, {"4th Contact Status", type text}, {"5th Contact Date", type datetime}, {"5th Contact Status", type text}, {"6th Contact Date", type datetime}, {"6th Contact Status", type text}}), 
    
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Last status", each List.Last(List.RemoveNulls(Table.SelectRows(Record.ToTable(\_), each Text.Contains(\_[Name],"Status",Comparer.OrdinalIgnoreCase))[Value]))), 
    
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Last date", each List.Last(List.RemoveNulls(Table.SelectRows(Record.ToTable(\_), each Text.Contains(\_[Name],"Date",Comparer.OrdinalIgnoreCase))[Value])), type date) 
    

    in

    #"Added Custom1"
    

    Hope this helps.

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2025-01-15T13:09:34+00:00

    Hello,

    Thank you for reaching out, Andreas solution worked for my post item!

    Thank you again for the assistance!

    0 comments No comments