How to display last answer, if there is more than one

Hi all,

I am trying to figure out, how to display just the last answer to my relevance, since there is more than one

Q: if (exists file “/var/test/agent/logs/test.log”) then unique values of (first matches (regex “[^\ .]+”) of following texts of firsts “Update succeeded to version” of lines starting with “2017” of file “/var/test/agent/logs/test.log”) else "N/A"
A: 8563
A: 8564

Thanks

Hi Brad,

If you want to filter that further to only return the “newest” version, you can try converting the results from strings to version objects, then you can get the “maximum” one. But that breaks your if/else since the if is returning a version and the else is returning a string. So this should work…

if (exists file "/var/test/agent/logs/test.log") then (maximum of (unique values of first matches (regex "[^\ .]+") of following texts of firsts "Update succeeded to version" of lines starting with "2017" of file "/var/test/agent/logs/test.log" as version) as string) else "N/A"

Or you could rework it a bit and do something like this, which uses the error handling operator to catch missing files and avoids typing out the file path twice:

maximum of (unique values of first matches (regex "[^\ .]+") of following texts of firsts "Update succeeded to version" of lines starting with "2017" of file "/var/test/agent/logs/test.log" as version) as string | "N/A"
1 Like

Thanks for the input, worked like a charm