Sorry if I am missing something obvious as I am trying to learn Qlik Sense.
I have a table with about 1 mil rows, I want to filter the data based the criteria below:
- Find the 1st Lost Charges for the serial
- Now switch the search to the serial + suffix where the Lost Charge was found and look for Lost Credits:
- a. If Lost Credits found - Ignore the data and continue to the next Lost Charges
- b. If Lost Credits not Found - Select all the data for that serial (entire serial, not just the suffix where Lost Charges was found) starting from the Lost Charges (Lost Charges not included)
- Repeat for each serial.
Example Data:
Serial Sfx Ser|Sfx Value Charge Date Charge Type
96 1 96|1 3.50 30/09/2002 Rental Charges
96 1 96|1 3.50 31/10/2002 Rental Charges
96 1 96|1 3.50 30/11/2002 Rental Charges
96 1 96|1 3.50 31/12/2002 Rental Charges
96 1 96|1 3.50 31/01/2003 Rental Charges
96 1 96|1 3.50 28/02/2003 Rental Charges
96 1 96|1 3.50 31/03/2003 Rental Charges
96 1 96|1 3.50 30/04/2003 Rental Charges
96 1 96|1 3.50 31/05/2003 Rental Charges
96 1 96|1 3.50 30/06/2003 Rental Charges
96 1 96|1 3.50 31/07/2003 Rental Charges
96 1 96|1 3.50 31/08/2003 Rental Charges
96 1 96|1 112.50 14/10/2003 Lost Charges
96 2 96|2 3.50 30/11/2003 Rental Charges
96 2 96|2 3.50 31/12/2003 Rental Charges
96 2 96|2 3.50 31/01/2004 Rental Charges
96 3 96|3 3.50 31/08/2005 Rental Charges
96 3 96|3 3.50 30/09/2005 Rental Charges
96 3 96|3 3.50 31/10/2005 Rental Charges
96 4 96|4 3.50 31/01/2006 Rental Charges
96 4 96|4 3.50 28/02/2006 Rental Charges
96 4 96|4 112.50 10/05/2006 Lost Charges
96 4 96|4 -112.50 15/05/2006 Lost Credits
Resulting data should be:
Serial Sfx Ser|Sfx Value Charge Date Charge Type
96 2 96|2 3.50 30/11/2003 Rental Charges
96 2 96|2 3.50 31/12/2003 Rental Charges
96 2 96|2 3.50 31/01/2004 Rental Charges
96 3 96|3 3.50 31/08/2005 Rental Charges
96 3 96|3 3.50 30/09/2005 Rental Charges
96 3 96|3 3.50 31/10/2005 Rental Charges
96 4 96|4 3.50 31/01/2006 Rental Charges
96 4 96|4 3.50 28/02/2006 Rental Charges
96 4 96|4 112.50 10/05/2006 Lost Charges
96 4 96|4 -112.50 15/05/2006 Lost Credits
I tried to do with just the set analysis, but couldn't get the desired results.
I have loaded the data and created a 2nd table to filter some the data that is pre 1st Lost Charges as per below:
ChargeData:
LOAD
Serial_KEY,
"Serial number true" as SerNo,
"Suffix number" as Sfx,
Value,
"Charge Date",
"Charge Type",
"Additional Text",
Customer,
"Invoice Document",
Currency,
"Charge Type" &'|'& Date([Charge Date]) as Charge_KEY
FROM [Transform.qvd]
(qvd);
LostCylinders:
Load
SerNo,
Concat(IF([Charge Type]='Lost Charges','L',
IF([Charge Type]='Lost Credits','C',Null()))) as LostFlag
Resident ChargeData
Group by SerNo
;
Then in the app a measure that sum all of the Lost Charges per Serial
sum({$<"Charge Type"={"Lost Charges"}>} Value )
But I am not sure how to make it only sum values after the 1st Lost Charges.