Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
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.

1 Solution

Accepted Solutions
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;

View solution in original post

22 Replies
gayatri7
Creator II
Creator II
Author

Hi Guys,

can anyone help me with this requirement. Its very urgent!!

vinieme12
Champion III
Champion III

please post a sample data that best replicates your scenario.

Are you working with a different data table for each month?

Can you post a sample qvw?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Kushal_Chawda

how your collections are changing? When you select April, 4562 is collection for Mar-16, and when you select Jun, 2400 is collection for Mar-16. Can you please provide he correct input?

gayatri7
Creator II
Creator II
Author

Hi Kushal,,

Yes it will change. Scenario is When I select April month it shows 4562 Rs. has been collected on the month of April for March and when I select June month it shows 2400 Rs has been collected on June for March month. User can pay the premium amount on any month.

I hope it will clarify the scenario.

gayatri7
Creator II
Creator II
Author

Hi Vineeth,

Sample data what I have posted replicates the scenario. Yes, I am working on different data file each month. Every month file will generate which indicates how much premium collection has been done for all the month.for eg. if user has to pay premium amount of his policy in the month of April, he can pay either advance (in the month of March) or late (either on May or june or july etc.) so every month file contains again date column which indicates month for which collection has been done.

I am not able to replicate the same in QVW but I have generated chart in excel and same is attached.

Kushal_Chawda

see the attached file

I am  considering that you have collection file for each month with file name like Collection_Apr_2016.xls....

Refer to below script

t1:

LOAD date(Month,'MMM YYYY') as Month, //Monthly Collection

    Collection,

    date#(replace(mid(FileBaseName(),index(FileBaseName(),subfield(FileBaseName(),'_',2))),'_',' '),'MMM YYYY') as CollectionMonth // Month of excel file

FROM

[..\Collection_*.xlsx]

(ooxml, embedded labels, table is Apr);

t2:

LOAD *,

    autonumber(Month) as Pointer

Resident t1

order by Month asc;

DROP Table t1;

Left Join

LOAD Distinct CollectionMonth,

    Pointer as PointerCollection

Resident t2

Where CollectionMonth=Month;

t3:

NoConcatenate

LOAD *,

    if(len(trim(Collection))=0 or Collection=0,Null(),Pointer-PointerCollection) as FinalPointer

Resident t2;

DROP Table t2;

Note:

In above script goal is to bring CollectionMonth & Month in same format 'MMM YYYY'

Capture1.JPG

Capture2.JPG

gayatri7
Creator II
Creator II
Author

Hi Kushal,

Thank you so much of your time!!!!

Solution looks very good to me. I will try with my data and let you know if any issues.

Thank you so much again.

Thanks

Gayatri

gayatri7
Creator II
Creator II
Author

Hi Kushal,

I have tried replicating the same logic but unable to do that. It is not calculating the  "PointerCollection" and FinalPointer both. Could you please see the attached QVW.

Kushal_Chawda

Hi,

File name should be consistent, files you have attached, in which one of the file name is Collection_June_2016, all Month name should be 3 digit i.e in MMM format. Otherwise formatting function Date# , will not work properly

Only one modification in script I have done which is working fine

Left Join (t2)

LOAD Distinct CollectionMonth,

    Pointer as PointerCollection

Resident t2

Where Trim(CollectionMonth)=Trim(Month);


I have attached only file name which I have renamed