+ Reply to Thread
Results 1 to 29 of 29

Looking up final value that can be tracked in table

  1. #1
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Looking up final value that can be tracked in table

    Hi,

    I have my data in Table 1 and the lookup criteria in Table 2, which represents specific rows taken from Table 1. I want to use the row number for these rows (as listed in column N) to get the results that I have listed in Table 3. Please see attached workbook.

    The rows that are colored in the same color are related in that they belong to the same Group (column A) and Code (column B) and that they are linked by timestamps (column D and E). For the linked rows, the timestamps work in such a way that the Changed timestamp (column E) of one row will be the Created timestamp (column D) of a row that represents a newer entry. There may be any number of linked rows for a given row, but the final - and thus most recent - linked row will always have the Code (column C) "false". All preceding linked rows will have the Code (column C) "true".

    It'd be great if someone knew how to track these results down with a formula.

    Best regards,
    Marbleking
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Hello!

    I have come up with a solution to this problem that uses iteration. It requires that iterative calculation is enabled:

    Options -> Formulas -> Enable iterative calculation

    I have put the following formula in cell R4:

    Please Login or Register  to view this content.
    And the following formula in cell Q4:

    Please Login or Register  to view this content.
    Please see updated workbook attached.

    PS: If someone is able to come up with a non-iterative solution, e.g. something involving array multiplications etc., that would be nice.

    Best regards,
    Marbleking
    Attached Files Attached Files

  3. #3
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Looking up final value that can be tracked in table

    Hi

    Try this in K4 (drag down and forward K4:M7)
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Use in O4 (drag down O4:O7)
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note: You can use real True or False in column C and in that case formula in O4 must be =IF(J4,INDEX...

    See the file for clarification

  4. #4
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Hi José Augusto and thank you,

    Your solution yields the correct results in this example. Your solution in O4:O7 rests on the assumption that for a given set of criteria in columns H and I where column J is "True", the correct results can be found by looking up the most recent timestamp which has the same criteria as given in columns H and I. But that may not always be the case in these data and I may have failed to capture that nuance in the example. It is true only when one can trace the timestamps in zig-zag between Created and Changed across the connected entries. I.e., there may be that the entry with the most recent timestamp actually is connected to a different "lineage" that coincidentally also share the criteria in columns H and I. Before I tried the iteration solution I tried to see if it was possible to use the "zero sum" that occurs if the relevant connected Created and Changed timestamps were substracted from each other, but that attempt stalled.

    Best regards,
    Marbleking

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Hi,

    Perhaps some more realistic and varied examples would be appropriate, then?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  6. #6
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Hi,

    See attached workbook. I have inserted a line in row 17 (purple) which helps illustrate the difference in results that may occur; please compare columns Q4:Q7 against S4:S7.

    Best regards,
    Marbleking
    Attached Files Attached Files

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    So effectively a search criterion of "false" will only ever necessitate locating one value within Table1, correct? It's only for a search criterion of "true" that 'tracing' is required in order to locate its corresponding first "false" entry in Table1?

    Regards

  8. #8
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Yes, that is correct, XOR LX!

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    This can probably be improved, though as a starter please test:

    =XLOOKUP(H4&"|"&I4&"|"&IF(J4="false",J4,LOOKUP(1,0/FREQUENCY(0,1/(1+((A$4:A$40=H4)*(B$4:B$40=I4)*(C$4:C$40=J4)*E$4:E$40))),E$4:E$40)),A$4:A$40&"|"&B$4:B$40&"|"&IF(J4="false",C$4:C$40,D$4:D$40),F$4:F$40)

    in row 4 and copied down.

    Regards

  10. #10
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Thank you, XOR LX!

    It's interesting to see the Frequency function in use. The solution yields wrong result for row 5 (second entry) of table 2; 1800,00% instead of 1,60%, matching row 17 in table 1 instead of the correct row 25 as given in table 2. Also, it looks like the frequency function, when in use for entries in table 2 that are "true", skips to the last entry in table 1 for which the criteria matches those given in column H, I and J of table 2 before locating the connected entry in table 1 which have "false". How does it make sure that the several identified "true" matches in table 1 are related, so that it skips to the correct last "true" entry? There is a link between row 21 and row 24 in table 1 through cells E21 and D24 because these are the same timestamps, but if E21 and D24 were not the same values then they wouldn't be related.

    Regards

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Not sure what data you're using, but my formula matches with all of your expected results for the workbooks you've thus far provided.

    Regards

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Quote Originally Posted by XOR LX View Post
    So effectively a search criterion of "false" will only ever necessitate locating one value within Table1, correct? It's only for a search criterion of "true" that 'tracing' is required in order to locate its corresponding first "false" entry in Table1?
    Quote Originally Posted by Marbleking View Post
    Yes, that is correct, XOR LX!
    Ah, wait, I see what you mean. So in fact the answer to my question should in fact have been in the negative?

    Regards

  13. #13
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Please see updated workbook. I added a few more "purple" lines, this time in row 25 and 26. In table 2, cells J5 and J6, the criterion is "false". These lines do not require said "tracing", as lines with "false" always will be "final destination". Thus, the results found in M5:M6 (and row numbers pointing to table 1 in N5:N6) will be equal to what is expected to be found in table 3. In table 2, cells J4 and J7, the criterion is "true" and so these need "tracing" to arrive at their corresponding "false" lines in table 1 and return the corresponding results. In the updated workbook, you'll also see how jumping directly to the most recent "true" line in table 1 that happens to match with columns H and I of table 2 may yield wrong results.

    Regards
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    09-20-2020
    Location
    india
    MS-Off Ver
    2013
    Posts
    1

    Copy cell formatting by vlook up

    Re:i need to copy data by using vlookup with cell and text formatting is there any macro .
    Last edited by streee07; 09-20-2020 at 12:53 PM.

  15. #15
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Any chance of a few more than 4 rows' worth of expected results? If you could add half a dozen more or so that would be very useful in terms of checking potential solutions.

    Regards

  16. #16
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Yes, I have updated the workbook so that the complete table 1 is now used as both data table (as originally) and criteria table at the same time. The newly added table 4 shows which results would be expected for each of the rows in table 1 when used as starting points.

    Regards,
    Marbleking
    Attached Files Attached Files
    Last edited by Marbleking; 09-20-2020 at 02:22 PM.

  17. #17
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Thanks a lot.

    However, I'm not sure I understand: the "Traced back result" does not equal the "Traced forward result" for all given rows. Which is to be taken as the desired result?

    Regards

  18. #18
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    The "traced forward result" corresponds to the original problem as per table 2 and table 3, so that is to be taken as the desired result. I added the "traced back result" because it constitutes a similar problem, only the other way around. Traced forward result will only equal traced back result in cases where there is only one entry (with criterion "false") that has no predecessors (with criterion "true"). Traced back checks if one can find predecessors, while trace forward checks if one can find successors.

    Regards
    Last edited by Marbleking; 09-20-2020 at 02:54 PM.

  19. #19
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Thanks. And can you just confirm that it's possible to have an entry with a criterion of "true" which is not linked to any other entry? Row 35 (123460|EE|true) is anomalous in being the only such case, so just thought I'd ask for confirmation.

    Regards

  20. #20
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Good catch; I have that line in there to account for the theoretical possibility, but I have never seen it in the actual data I am working with. If it creates a problem, you could change the criterion to "false", otherwise it can be kept in place as it is, if it can be accommodated into a solution.

    Regards

  21. #21
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Ok. This agrees with all the results in that file though please check and get back to me.

    In row 4 and then copied down:

    =IF(C4="true",IFNA(XLOOKUP(A4&"|"&B4&"|false|"&SMALL(IF(A$4:A$42=A4,IF(B$4:B$42=B4,IF(D$4:D$42>=D4,E$4:E$42))),-LOOKUP(1,-XMATCH({0,1},N(MMULT(SMALL(IF(A$4:A$42=A4,IF(B$4:B$42=B4,IF(D$4:D$42>=D4,D$4:E$42))),SEQUENCE(COUNTIFS(A$4:A$42,A4,B$4:B$42,B4,D$4:D$42,">="&D4)-1,2,2)),{-1;1})<>0),0,{-1,1}))),A$4:A$42&"|"&B$4:B$42&"|"&C$4:C$42&"|"&E$4:E$42,F$4:F$42,,,-1),F4),F4)

    Regards

  22. #22
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    That's awesome. I think you've nailed it. I need to work through this in detail tomorrow, and come back to you, but I'm very optimistic this time.

    If you'd like to modify it into a version that yields the "traced back results" too, that'd be cool.

    Thank you very much.

    Regards

  23. #23
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Quote Originally Posted by Marbleking View Post
    If you'd like to modify it into a version that yields the "traced back results" too, that'd be cool.
    No brain cells left for that part right now!

  24. #24
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Quote Originally Posted by XOR LX View Post
    No brain cells left for that part right now!
    I'm impressed that someone had brain cells for the first part, so I understand. Have a nice evening in Turin.

  25. #25
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Looking up final value that can be tracked in table

    Quote Originally Posted by Marbleking View Post
    I'm impressed that someone had brain cells for the first part, so I understand. Have a nice evening in Turin.
    Thanks! And to you too there!

    Cheers

  26. #26
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Hi, XOR LX! I have tested your formula with various data today and it produces the correct results consistently, although there are some magic in there that I haven't yet been able to decipher. Very happy with this. Regards, Marbleking

  27. #27
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742
    Glad to hear it!

    I can post a brief explanation if you haven't worked out the logic yourself after a few days.

    Cheers

  28. #28
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Good afternoon, XOR LX!

    I am again looking for a related formula to what you provided in this example, but this time I need the "traced back results" as indicated in the earlier attachment. Would you be able to modify the "traced forward results" formula to accommodate this, please?

    Please Login or Register  to view this content.
    Is it also possible to make it a dynamic array formula that automatically adjusts to the table size instead of having to be pulled down from row to row?

    Best regards,
    Marbleking

  29. #29
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Looking up final value that can be tracked in table

    Hi,

    I have attached an updated workbook that illustrates relationships between various data points. I am looking for a dynamic array formula that spills the results in Table 5. The correct results can be seen in Table 4. These results have been obtained using an iteration solution (Options -> Formulas -> Enable iterative calculation). These results come from looking at lines in Table 1 that belongs to the same Group and Code and where the timestamp seen in the column "Created" can be traced back to similar lines which have that same timestamp in their "Changed" column, in a zig-zag fashion. (See rows 25, 21 and 18 in column G as an example).

    Table 2 and Table 3 shows solutions to the related problem of tracing forwards instead of backwards. The array solution in Table 3 was created by XOR LX and can serve as a good starting point.

    I hope someone are able to come up with a solution to this.

    Thanks,

    Marbleking

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel Tracked Changes Help?
    By khays2011 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-26-2016, 12:06 PM
  2. Remove tracked changes?
    By MetroBOS in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 06-05-2015, 01:27 PM
  3. removing data from a table and getting a final result
    By Jimbras in forum Excel General
    Replies: 1
    Last Post: 11-26-2014, 09:10 AM
  4. Replies: 1
    Last Post: 03-17-2014, 04:18 AM
  5. Creating a Final Estimate Form and a Final Materials List based on Worksheet Results
    By Crunched For Time in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-20-2013, 09:58 PM
  6. VBA Tracked Changes HELP
    By amardeep20 in forum Word Programming / VBA / Macros
    Replies: 10
    Last Post: 03-15-2013, 02:58 PM
  7. replacing lowest test grade with final if final is higher formula help
    By colbyclay in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-16-2012, 02:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1