Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Chart Expression Assistance

Hello!

I'm stuck on an expression for a chart I'm putting together.

Data is laid out as per the table below.  This is a very small subset.

PKT_CTRL_NBRDIVCHANNELCREATE_DATEPRINT_DATEUNITS
8370650WHOLESALEWHOLESALE12/14/201501/13/201613
8370651WHOLESALEWHOLESALE12/15/201501/06/201626
8370652WHOLESALEWHOLESALE12/29/201501/04/20166581
8370653RETAILDOS12/29/201501/04/20164546
8370654WHOLESALEWHOLESALE12/30/201501/04/20162167
8370655RETAILDOS12/30/201501/04/20162167
8370656WHOLESALEWHOLESALE12/30/201501/05/2016264
8370657RETAILDOS12/30/201501/08/20161996
8370658WHOLESALEWHOLESALE12/31/201501/04/20161000
8370659RETAILDOS12/31/201501/04/2016891
8370660WHOLESALEWHOLESALE12/31/201501/08/2016100
8370661RETAILDOS12/31/201501/08/2016236
8370662WHOLESALEWHOLESALE12/31/201501/12/2016576
8370663RETAILDOS12/31/201501/13/2016100
8370664WHOLESALEWHOLESALE12/31/201501/13/2016194
8370665WHOLESALEWHOLESALE01/01/201601/04/2016101
8370666WHOLESALEWHOLESALE01/03/201601/04/2016500
8370667RETAILDOS01/03/201601/04/2016768
8370668WHOLESALEWHOLESALE01/03/201601/05/2016500
8370669RETAILDOS01/03/201601/05/2016526
8370670WHOLESALEWHOLESALE01/03/201601/06/2016200
8370671RETAILDOS01/03/201601/06/2016298
8370672WHOLESALEWHOLESALE01/04/201601/04/2016192
8370673RETAILDOS01/04/201601/05/20168426
8370674WHOLESALEWHOLESALE01/04/201601/06/20161107
8370675RETAILDOS01/04/201601/13/2016124
8370676WHOLESALEWHOLESALE01/04/201601/20/201694
8370677RETAILDOS01/04/201601/26/201681

What I'm trying to show is how many UNITS were available to print each day. 

What I'd like to see is something like this:

PRINT_DATEUNITS_CREATEDUNITS_PRINTEDUNITS_AVAILABLE
01/04/2016100241891333774

Then the pattern would repeat for each day.  The units available would be the total of units printed that day and units created but not yet printed.  Is this even possible?  Any help would be fantastic.

12 Replies
swuehl
MVP
MVP

So units available also considers units that have been created before that date?

kkkumar82
Specialist III
Specialist III

Hi,

What is your logic for UNITS Created, UNITS_PRINTED, UNITED PRINTED can you brief out.

If possible give your data in an excel or comma separated so that it will easy for us to load.

jonathandienst
Partner - Champion III
Partner - Champion III

Assuming the data is loaded as per your post into table "Data1", then load like this:

Data2:

NoConcatenate

LOAD CREATE_DATE as ReportDate,

    Sum(UNITS) as UnitsCreated

Resident Data1

Group By CREATE_DATE;

Join(Data2)  

LOAD PRINT_DATE as ReportDate,

    Sum(UNITS) as UnitsPrinted

Resident Data1

Group By PRINT_DATE;

  

Join(Data2)

LOAD ReportDate,

    RangeSum(UnitsCreated, -Previous(UnitsPrinted), Peek(UnitsAvailable)) as UnitsAvailable

Resident Data2

Order by ReportDate;

Then create a table with ReportDate as dimension and Sum(UnitsCreated), Sum(UnitsPrinted), Sum(UnitsAvailable) as expressions:

t1.png

EDIT - fixed missing '-' sign....

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
kkkumar82
Specialist III
Specialist III

Hi Jonathan,

Could you please elaborate

RangeSum(UnitsCreated, -Previous(UnitsPrinted), Peek(UnitsAvailable)) as UnitsAvailable 


The above line especially -Previous(UnitsPrinted)



Anonymous
Not applicable
Author

Correct.

If the Print Date is 1/4.  The available total should include everything Created on 1/4 or before that has not yet been Printed.

Anonymous
Not applicable
Author

Hello,

The Create Date for a unit is the date it is transferred from SAP into my warehouse system.

The Print Date is the day the warehouse begins processing the units.

I've attached a larger set of data in a .txt file.

Thanks,

Kevin

Anonymous
Not applicable
Author

Here's what the data looks like in a Pivot Chart.  Print Date is across the top.pivot.PNG

Anonymous
Not applicable
Author

Hello,

Thanks for this sample.  I loaded the csv file sample I uploaded above and the numbers work.

How would you load the keeping the other fields?

qliksus
Specialist II
Specialist II

Hi ,

You can also use something like this

Script :

avail:
LOAD PKT_CTRL_NBR,
     DIV,
     CHANNEL,
     'C' as Flag,
     CREATE_DATE as Date,
    
     UNITS
FROM
available_test.csv
(txt, utf8, embedded labels, delimiter is ',', msq, no eof);

LOAD PKT_CTRL_NBR,
     DIV,
     CHANNEL,
     'P' as Flag,
   
     PRINT_DATE as Date,
     UNITS
FROM
available_test.csv
(txt, utf8, embedded labels, delimiter is ',', msq, no eof);
;

Created : sum({<Flag={'C'}>}UNITS)

Printed:  sum({<Flag={'P'}>}UNITS)

Available: sum({<Date={"<=$(=date(only(Date)))"},Flag={'C'}>}UNITS)