Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
leon511920
Contributor III
Contributor III

Differences between data

I want the difference between data A at the time of the maximum date and data A at the time of the second maximum date to be the axis of the scatter plot.

how do i calculate it?
----------------------------------------------
I wanna calculate this :
=291-013
----------------------------------------------
Date                    | dataA
2021/02/23       123
2021/02/24       291       
2021/03/23       201
2022/04/10       013
2023/01/21       291

8 Replies
sidhiq91
Specialist II
Specialist II

@leon511920 Can you please post how the expected output should look like?

leon511920
Contributor III
Contributor III
Author

The red part is error.

x-axis: [customer]
y-axis: if([date] = max(date), dataA) - if([date] = max(date,2), dataA)

test.png

tresesco
MVP
MVP

Not sure about the presentation, you can try like:

 if([date] = max(total date), dataA) - if([date] = max(total date,2), dataA)

leon511920
Contributor III
Contributor III
Author

Thank you for your advice,
but I got a message that the chart is not displayed because only undefined values are defined.....

There is no error with
"if([date] = max(total date), dataA)",

but an error occurs with
if([date] = max(total date), dataA) - if([date] = max(total date,2), dataA)".

 

sidhiq91
Specialist II
Specialist II

@leon511920  Please see the code below:

NoConcatenate
Temp:
Load Date(Date#(Date,'YYYY/MM/DD'),'MM/DD/YYYY') as Date,
dataA
Inline [
Date, dataA
2021/02/23, 123
2021/02/24, 291
2021/03/23, 201
2022/04/10, 013
2023/01/21, 291
];

NoConcatenate
Temp1:
Load Date,
dataA,
dataA-Previous(dataA) as Difference
Resident Temp
Order by Date asc;

Drop table Temp;

Exit Script;

Let me know if this helpful.

sidhiq91
Specialist II
Specialist II

@leon511920  Please see the screen shot below:

sidhiq91_0-1676441587751.png

 

leon511920
Contributor III
Contributor III
Author

Oh thank you,
but what I want to do is
the plot the difference of the data with respect to the highest value of the date and the second highest value of the date.(only two date:maximum date and second maximum date).
(sorry its my bad)

I want to plot the difference between the values of data A when the date is the largest and data A when the date is the second largest.

[scatter plot]
x-axis :number
y-axis : if([date] = max(date), dataA) - if([date] = max(date,2), dataA)

leon511920
Contributor III
Contributor III
Author

in this case:

Max(date) = 2022/10/11 , dataA = 100
Max(date,2) = 2021/09/46 , dataA = 28    -----> 100-28=72


[scatter plot]
x-axis :Number
y-axis : if([date] = max(date), dataA) - if([date] = max(date,2), dataA)

Date DataA Number
2021/01/02 102 1
2021/01/02 102 2
2021/09/46 28 1
2021/09/46 28 2
2022/10/11 100 1
2022/10/11 100 2
2020/07/15 4 1
2020/07/15 4 2