Power Query: Rows Comparison

Jeremy Loh 21 Reputation points
2021-05-28T10:14:55.587+00:00

Hi guys,

I would like to compare the rows of my dataset using power query. The logic is as follows:

  • If user's actions are "Open" & "Click" within 5 minutes and IP address is the same for both actions, then status for the user is "1", else "0".

Appreciate if anyone can help me with the logic.

You may refer the dataset "before" & "after" as attached.

100468-image.png

Community Center | Not monitored
{count} votes

Answer accepted by question author
  1. Lz._ 38,106 Reputation points Volunteer Moderator
    2021-05-30T11:07:19.727+00:00

    Hey @Anonymous

    Final version is available here. I shortened and improved function AddRecipientStatus in term of perf.
    Put comments in the different querie's code => hopefully they answer your question

    Power Query M documentation is available here. If you want pointers for learning purpose let me know


3 additional answers

Sort by: Most helpful
  1. Lz._ 38,106 Reputation points Volunteer Moderator
    2021-05-28T18:21:10.36+00:00

    @Anonymous

    Could you check this first version:

    • Check the current results
    • Add some more records to the TestTable

    and let me know what doesn't work as expected


  2. Lz._ 38,106 Reputation points Volunteer Moderator
    2021-05-29T10:12:38.077+00:00

    @Anonymous . Could you play with this version and check?

    Notes:

    • You have to download/save a local copy otherwise you'll be in View Only mode in Excel Online
    • The result of the query is currently not reordered as in the source table so it's easier to follow the sequence by Recipient

  3. Lz._ 38,106 Reputation points Volunteer Moderator
    2021-05-30T09:11:45.65+00:00

    Hi @Anonymous

    Your remarks definitively helped => Implemented the corresponding logic. I did a few checks against my TestTable and this seems good to me. Double check and confirm please. If a [Status] isn't good, same as yesterday give me a remark explaining why (the [ROW] column has been temporarily added for that)

    Note that this version doesn't reorder the records as in the source table to facilitate your checks. I'll do the cleanup and reorder if result is OK on your side


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.