Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional display of data on a straight table

Hi guys,

I have quick question. I hope someone has a simple answer.

I have the following data output in a straight table where CLIENT_KEY and DATE are dimension fields and AMOUNT is an expression.

CLIENT_KEYDATEAMOUNT
R101505-Sep-12-18,192
R101506-Sep-122,889
R101510-Sep-125,819
R172018-Sep-126,450
R172028-Sep-12-70
R172001-Oct-12-23
R172004-Oct-121,678

I would like to only display the latest positive AMOUNT values for a given CLIENT_KEY. So it would be chronogically all the positive values for AMOUNT till it becomes negative. The data i would like to be removed from the table is can striked through. Does anyone have any ideas as to how it can be done?

CLIENT_KEYDATEAMOUNT
R101505-Sep-12-18,192
R101506-Sep-122,889
R101510-Sep-125,819
R172018-Sep-126,450
R172028-Sep-12-70
R172001-Oct-12-23
R172004-Oct-121,678
1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try this for T2:

T2:

Load

          CLIENT_KEY,

          DATE,

          if(Peek(CLIENT_KEY)<>CLIENT_KEY,AMOUNT,if(Peek(NEW_AMOUNT)>0 and POS_FLAG=1,AMOUNT)) as NEW_AMOUNT,

          if(Peek(CLIENT_KEY)<>CLIENT_KEY,AMOUNT,Peek(ACCUM_AMOUNT)+AMOUNT)) as ACCUM_AMOUNT

resident T1

order by CLIENT_KEY, DATE desc;


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
sivarajs
Specialist II
Specialist II

Try with this expression if(sum(AMOUNT)>0,sum(AMOUNT))

Not applicable
Author

Hi faisalza,

Yu can make use of the Dimension Limits feature.

Go to Properties--> Dimension Limits-->Limits--> Show only values that are

Select --> Values that are greater than or equal to and mention 0 since you need +ve values to be shown, selct exact amount in the next field.

Regards

Satheesh

Anonymous
Not applicable
Author

Here's one way that seems to work:

T1:

Load

          CLIENT_KEY,

          Date(Date#(DATE,'DD-MMM-YY')) as DATE,

          AMOUNT,

          if(AMOUNT>0,1) as POS_FLAG;

LOAD * INLINE [

    CLIENT_KEY, DATE, AMOUNT

    R1015, 05-Sep-12, "-18192"

    R1015, 06-Sep-12, "2889"

    R1015, 10-Sep-12, "5819"

    R1720, 18-Sep-12, "6450"

    R1720, 28-Sep-12, -70

    R1720, 01-Oct-12, -23

    R1720, 04-Oct-12, 1678

];

T2:

Load

          CLIENT_KEY,

          DATE,

          if(Peek(CLIENT_KEY)<>CLIENT_KEY,AMOUNT,if(Peek(NEW_AMOUNT)>0 and POS_FLAG=1,AMOUNT)) as NEW_AMOUNT

resident T1

order by CLIENT_KEY, DATE desc;

Drop Table T1;

Anonymous
Not applicable
Author

hi faisal

Plz find attached

Not applicable
Author

Thanks Johannes Sunden,

This works. I tried it with different data sets.

I was hoping to do it this after the load, because the AMOUNT values in the DB are chronologically accumulated after they are loaded,

Im assuming these values could be cumulated in the load. How would i chronologically accumulate AMOUNT values for every client in the script ?

Regards

Faisal

Gysbert_Wassenaar

Try this for T2:

T2:

Load

          CLIENT_KEY,

          DATE,

          if(Peek(CLIENT_KEY)<>CLIENT_KEY,AMOUNT,if(Peek(NEW_AMOUNT)>0 and POS_FLAG=1,AMOUNT)) as NEW_AMOUNT,

          if(Peek(CLIENT_KEY)<>CLIENT_KEY,AMOUNT,Peek(ACCUM_AMOUNT)+AMOUNT)) as ACCUM_AMOUNT

resident T1

order by CLIENT_KEY, DATE desc;


talk is cheap, supply exceeds demand