Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Data from charts in variable

Hi everyone! Suppose I have this chart that shows some quantity per day.

DayQ
1/8/20182
2/8/20185
3/8/20188
4/8/20189
5/8/20187
6/8/20181
7/8/20186
8/8/20187

I need to do this. Every time I choose a date, I need to compare the Q of the day selected with the Q that is recorded 7 days before.

Example

I choose 8/8/2018. Q = 7

I need to get the Q = 2 for the day 1/8/2018, so I can calculate 7-2

How can I do this? Thanks!

5 Replies
m_woolf
Master II
Master II

Something like (I didn't test):

=sum(Q) - sum({<Day={"$(=Day-7)"}>} Q)

MarioCenteno
Creator III
Creator III

Try

expression the last week - today

(sum({<Day={">=$(=Date(today()-7,'MM/DD/YYYY'))<=$(=Date(today(),'MM/DD/YYYY'))"}>}Q)


-


sum({<Day={">=$(=Date(today(),'MM/DD/YYYY'))<=$(=Date(today(),'MM/DD/YYYY'))"}>}Q)


)


Anonymous
Not applicable
Author

I think this sentence "{<Day={"$(=Day-7)"}>} Q" is an "if-then" sentence that can be written like this, correct?

If(Day = "$(=Day-7)", Q)

I do not know what I'm doing wrong. The sentence works, but brings me the Q for 8/8/2018 instead of  1/8/2018...


Consider that when I select a date, the chart shows one row only. Maybe the problem resides in this fact?

m_woolf
Master II
Master II

Are you trying to show the difference in the chart, or in a text object?

Can you share a sample qvw?

Anonymous
Not applicable
Author

Sure! Here you have a sample. Blue box activates when you select a date.