Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ngrunoz
Contributor II
Contributor II

Running Total Limited By SubTotals

Hi.

I have a scenario where I have to do a delivery Schedule  from one Customer to the next. I therefore need to have a running Total from 1st Customer to the next  to a total QTY of let say 25 for each Suburb as this will be the total QTY which each truck can carry at a given time. How best can I approach this.

1 Solution

Accepted Solutions
effinty2112
Master
Master

Hi Rungano,

Try:

Data:

LOAD CITY,

     TOWN,

     SURBURB,

     CUSTOMER,

     QTY

FROM

[Delivery Schedule.xlsx]

(ooxml, embedded labels, table is Sheet1);

Left Join (Data)

Load

SURBURB,

CUSTOMER,

     if(Peek(SURBURB) =SURBURB, QTY + Peek(RunningQty),QTY) as RunningQty,

     SURBURB & ' - ' & Div(24+if(Peek(SURBURB) =SURBURB, QTY + Peek(RunningQty),QTY),25) as Truck

Resident Data

     Order by CITY, TOWN,  SURBURB;

To get this:

CITY TOWN SURBURB CUSTOMER QTY RunningQty Truck
C1T1S1C155S1 - 1
C1T1S1C21015S1 - 1
C1T1S1C31227S1 - 2
C1T1S1C4633S1 - 2
C1T1S1C5336S1 - 2
C1T1S2S2C11515S2 - 1
C1T1S2S2C21227S2 - 2
C1T1S2S2C32249S2 - 2
C1T1S2S2C41059S2 - 3
C1T1S3S3C51313S3 - 1
C1T1S4S4C11111S4 - 1
C1T1S4S4C2920S4 - 1
C1T1S4S4C31838S4 - 2
C1T1S4S4C42361S4 - 3
C1T2T2SS1T2SSC144T2SS1 - 1
C1T2T2SS1T2SSC2610T2SS1 - 1
C1T2T2SS1T2SSC3919T2SS1 - 1

Cheers

Andrew

View solution in original post

6 Replies
Anil_Babu_Samineni

What is the expected result from given data?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ngrunoz
Contributor II
Contributor II
Author

The expectation is to find Which Customers will be serviced by Which Truck and which Truck has been used to full capacity and below Capacity based on the 25 tons (QTY) capacity.

Customers Grouped by Suburb and Town to a maximum of 25 tons.

Hope I have explained it in a way that's understandable.  

Anil_Babu_Samineni

may be explanation clear, Better if you provide output from data set which provided by you

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
effinty2112
Master
Master

Hi Rungano,

Try:

Data:

LOAD CITY,

     TOWN,

     SURBURB,

     CUSTOMER,

     QTY

FROM

[Delivery Schedule.xlsx]

(ooxml, embedded labels, table is Sheet1);

Left Join (Data)

Load

SURBURB,

CUSTOMER,

     if(Peek(SURBURB) =SURBURB, QTY + Peek(RunningQty),QTY) as RunningQty,

     SURBURB & ' - ' & Div(24+if(Peek(SURBURB) =SURBURB, QTY + Peek(RunningQty),QTY),25) as Truck

Resident Data

     Order by CITY, TOWN,  SURBURB;

To get this:

CITY TOWN SURBURB CUSTOMER QTY RunningQty Truck
C1T1S1C155S1 - 1
C1T1S1C21015S1 - 1
C1T1S1C31227S1 - 2
C1T1S1C4633S1 - 2
C1T1S1C5336S1 - 2
C1T1S2S2C11515S2 - 1
C1T1S2S2C21227S2 - 2
C1T1S2S2C32249S2 - 2
C1T1S2S2C41059S2 - 3
C1T1S3S3C51313S3 - 1
C1T1S4S4C11111S4 - 1
C1T1S4S4C2920S4 - 1
C1T1S4S4C31838S4 - 2
C1T1S4S4C42361S4 - 3
C1T2T2SS1T2SSC144T2SS1 - 1
C1T2T2SS1T2SSC2610T2SS1 - 1
C1T2T2SS1T2SSC3919T2SS1 - 1

Cheers

Andrew

ngrunoz
Contributor II
Contributor II
Author

Thanks So much.

effinty2112
Master
Master

You're very welcome Rungano!