Discussion Board for collaboration related to QlikView App Development.
I have a list of users and their value for every day want to compare between latest Value to previous value,
what would be the most efficient way to do it?
Solved! Go to Solution.
Use the above() or before() function, depending on the layout of your table/chart. Something like sum(Value)/before(sum(Value))-1
thank you for your reply,
to create a field that will hold the change between today() and today()-1
is it possible to do in in the script?
Very likely. You will probably have to sort your table first and then you can use the previous() or peek() function to retrieve values from a previous record.
the table structure is: user_id, date, value
can you explain how to use peek function to calculate ( latest value / previous value) per user?
appreciate your help
If the data is sorted by user_id first and by date second then you can use something like if(previous(user_id)=user_id,peek(value)) as previous_value
I did it like this:
if (previous(ACCOUNT_ID)=ACCOUNT_ID,Peek('value', -2)) as PreviousValue,
peek('value',-1) as CurrentValue
Order by ACCOUNT_ID, date;
but I receive more than 2 values per each account, is there a way to load just the 2 last values?
Ok, if you only want to top 2 values per account try this:
ACCOUNT, Max(value) as LargestValue, Max(value,2) as SecondLargestValue
Group By ACCOUNT;
I need the Latest Value and the second Latest.. not the biggest
tried it also like:
num(peek('value',-1,'ACCOUNT_ID')) as CurrentValue,
num(peek('value',-2,'ACCOUNT_ID')) as PreviousValue
//Max(value) as LargestValue,
//Max(value,2) as SecondLargestValue
Group By ACCOUNT_ID;
did not work:(