Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mikael-c
Contributor III
Contributor III

using set analysis with total qualifier to return max value based on condition

I have a table with 3 fields: timestamp, name, value.

I want to return the value if the name equals a certain value ("ABC" in this example) and the timestamp is the most recent (data is updated regularly).

I already have this expression which works perfectly:

=aggr(if(timestamp = max(Total <name> timestamp) and name = 'ABC', max(value)), name, timestamp)

However, now I realized that I need to include this in a set analysis statement to prevent the value being changed by selections. From what I gather, I need to add {1} inside the max() function, however I have no idea how exactly to insert it, since my multiple tests have failed. Also, I wonder if I have to add it to other parameters since the if() statement is inside and aggr() function.

Thanks for your help!

1 Solution

Accepted Solutions
sunny_talwar

Try this

=Only({1} Aggr(If(Only({1} timestamp) = Max({1} TOTAL <name> timestamp) and Only({1} name) = 'ABC', Max({1} value)), name, timestamp))

View solution in original post

2 Replies
sunny_talwar

Try this

=Only({1} Aggr(If(Only({1} timestamp) = Max({1} TOTAL <name> timestamp) and Only({1} name) = 'ABC', Max({1} value)), name, timestamp))
mikael-c
Contributor III
Contributor III
Author

That was fast! Thank you, it works!
I will go read a little bit about only(). 🙂

Thanks!