Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
gayatri7
Creator II
Creator II

Need to create a comparison chart based on Period

Hi,

I want to make a chart which shows the below details in Qlikview.  For eg.

Data selected for Collection month April

April
MonthCollection
-3Jan-1624000
-2Feb-162406
-1Mar-164562
0Apr-1649000
1May-165000
2Jun-164000
3Jul-162000
4Aug-1610
5Sep-16

5

 

Data selected for Collection month June

June
MonthCollection
Jan-16
-4Feb-1640
-3Mar-162400
-2Apr-1624
-1May-163000
0Jun-1650000
1Jul-165100
2Aug-163000
3Sep-161000
4Oct-16500
5Nov-1650
6Dec-165

Now the chart should compare the period wise. if I select Apr for first period it should consider as period 0 and rest month should get calculated accordingly. And if second period is June, June should be consider as Period 0. and chart should compare the period 0 of 1st table to period 0 of second table. As shown below

 

Y Axis
X AxisAprilJune
-4040
-3240002400
-2240624
-145623000
04900050000
150005100
240003000
320001000
410500
5550
605

Attached is the chart created in excel.

22 Replies
gayatri7
Creator II
Creator II
Author

Hi Kushal,

Thanks for your quick response!!!

I am having another issue. For eg. For collection month April, I am having multiple dates for march month, Pointer variable is creating a separate values for each dates. And at the end I am having final pointer value as -1, -2 and -3 but I want for April collection month , march should be grouped by and consider as -1 only.

Image 1.PNG

As in real time data, I have multiple dates of same month in Collection file. and below is the table created based on real time data.

image 2.PNG

Sample file with QVD attached.

Kushal_Chawda

You need to perform group by in your script

Data:

LOAD *,

         date(Month,'MMM YYYY') as Month

FROM Source;

Final:

noconcatenate

LOAD Poliza,

          Month,

          CollectionMonth,

          Sum(Collection) as Collection

Resident Data

Group by

Poliza,

          Month,

          CollectionMonth;

drop table Data;

gayatri7
Creator II
Creator II
Author

Hi ,

I tried doing group by but still data is not coming as expected. Attached is the file.

Could you please help.

Kushal_Chawda

which field I need to refer for Collection?

gayatri7
Creator II
Creator II
Author

[Monto Pago] is field in the attahced file which is referring to Collection amount.

Kushal_Chawda

also do you need these fields for any reasons?

[Fecha Ingreso],

     [Fecha Efectiva],

[Fecha Recepción],

     [Fecha Cargo],

[Fecha Emisión],

gayatri7
Creator II
Creator II
Author

No I don't need all those fields. Only I want Month(VCTO_Recibo), Collection Month(from File name), Poliza and [Monto Pago] (Collection amount)

Kushal_Chawda

see this.. 

Póliza and Month has one to one relation. Also can you please send proper input file> or you can attach QVD file

Data:

LOAD Póliza,

     Date(floor(timestamp#([Vcto Recibo],'DD-MM-YYYY hh:mm:ss')),'MMM YYYY') as Month,

     date#(replace(mid(FileBaseName(),index(FileBaseName(),subfield(FileBaseName(),'_',2))),'_',' '),'MMM YYYY') as CollectionMonth,

     [Monto Pago]

FROM

[Recaudacion_Apr_2016.qvd]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

Recaudacion:

NoConcatenate

LOAD Póliza,

     sum([Monto Pago]) as [Monto Pago],

     Month,

     CollectionMonth

Resident Data

Group by Póliza,

      Month,

      CollectionMonth;

DROP Table Data;

Rec2:

LOAD *,

    autonumber(Month) as Pointer

Resident Recaudacion

order by Month asc;

DROP Table Recaudacion;

Left Join (Rec2)

LOAD Distinct CollectionMonth,

    Pointer as PointerCollection

Resident Rec2

Where trim(Month)=trim(CollectionMonth);

Rec3:

NoConcatenate

LOAD *,

    if(len(trim([Monto Pago]))=0 or [Monto Pago]=0,Null(),Pointer-PointerCollection) as FinalPointer

Resident Rec2;

DROP Table Rec2;

gayatri7
Creator II
Creator II
Author

Thank u so much for your time. Its working for me!!!!

Kushal_Chawda

glad that working fine