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

need help in pick function

Hallo,

I have used following function to get difference between two months but unable to get result in Qlikview.

If(month = 'jan',0, data - Pick (data, -1)) as Difference


Can anybody help me with it.

Best regard

Kazi

 

MonthSalesDifference
Jan10000
Feb1200200
Mar1250
Apr1500
1 Solution

Accepted Solutions
MarcoWedel

one example using a chart expression rather than generating the Difference field in the script:

QlikCommunity_Thread_301877_Pic2.JPG

QlikCommunity_Thread_301877_Pic3.JPG

hope this helps

regards

Marco

View solution in original post

7 Replies
vishsaggi
Champion III
Champion III

Are you looking for this?

Capture.PNG

IF yes you can try like below:

SalesDiff:

LOAD *, IF(Month = 'Jan', 0, Sales - Previous(Sales)) AS Diff INLINE [

Month, Sales

Jan, 1000

Feb, 1200

Mar, 1250

Apr, 1500

];

Then use straight table and add

Dim: Month, Sales

Expr: Diff

Then uncheck suppress 0 values in Presentation tab.

MarcoWedel

Did you mistake Pick for Peek?

Pick

Peek

regards

Marco

geam1988
Creator
Creator
Author

Hallo Vishwarath Nagaraju, thank you for your reply.  if there is any change in sales value, do i always have to change the sales value in schript ?    is it possible to do smothing in expressions ?

geam1988
Creator
Creator
Author

Hallo Marco Wedel,

i am talking about pick . i am looking for solution. if the result came from another function i have no problem to use that.

vishsaggi
Champion III
Champion III

I don't find any reason that you have to change your sales. Am i missing something? Please elaborate the issue. Do the script solution not work for you?

MarcoWedel

Hi,

one possible solution using Peek instead of Pick might be:

QlikCommunity_Thread_301877_Pic1.JPG

table1:

LOAD Month(Date#(Month,'MMM')) as Month,

    Sales,

    Alt(Sales-Peek(Sales),0) as Difference

FROM [https://community.qlik.com/thread/301877] (html, codepage is 1252, embedded labels, table is @1);

hope this helps

regards

Marco

MarcoWedel

one example using a chart expression rather than generating the Difference field in the script:

QlikCommunity_Thread_301877_Pic2.JPG

QlikCommunity_Thread_301877_Pic3.JPG

hope this helps

regards

Marco