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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set of analysis - count if different from one month to the other

Hello .. I am using the following questions ..

I have a base that accumulates license plate location over time as below:

Matrícula     Mês       Local

1                jan/15     A

1                fev/15      A

1               mar/15     B

1               abr/15      B

2                jan/15      A

2                fev/15      B

2               mar/15      B

2               abr/15       B

I want to display a table showing the amount of registrations that have changed location (compared to the previous month only) .. would look like this:


Local     Qtde Movimentações

A          20

B          18

This would vary according to the the month of selection, for example, if it is not selected any month qtas wanted people changed location (compared to the previous month) for the entire period. But if only selected the month of Apr / 15 for example in the table I wanted to show me only those where the site has been altered in Mar / 15 to Apr / 15.

Is it possible to do this?

7 Replies
maxgro
MVP
MVP

what about adding a flag in the script to identify the change of location?

in your example 2 records

                                                            flag

1                mar/15     B          1

2                     fev/15          B              1

other records                                    0

Not applicable
Author

I thought this hypothesis but I could not move , how could I put this flag through the script? Through joint analysis I thought it could be easier
Qrishna
Master
Master

Hi,

what would be the output for the provided data

Matrícula     Mês       Local

1                jan/15     A

1                fev/15      A

1               mar/15     B

1               abr/15      B

2                jan/15      A

2                fev/15      B

2               mar/15      B

2               abr/15       B


be like?


is it


Local    Changes

A          0

B          1   


?1.PNG

Not applicable
Author

not to the data provided would be ( considering the whole period) :


Local    Changes

A          1

B          1


but for example if the user selects the month of March / 15 then I would have :


Local    Changes

A          1

B          0

maxgro
MVP
MVP

a:

load *, date(date#(Right(Mês,2) & left(Mês,3), 'YYMMM')) as Date inline [

Matrícula     Mês       Local

1                jan/15     A

1                fev/15      A

1               mar/15     B

1               abr/15      B

2                jan/15      A

2                fev/15      B

2               mar/15      B

2               abr/15       B

22                jan/15      A

22                fev/15      B

22               mar/15      A

22               abr/15       B

] (delimiter is spaces);

aa:

load

  Matrícula,

  Mês,

  Local,

  Date,

  if(Peek(Matrícula)=Matrícula and Peek(Local)<>Local, 1, 0) as Flag

Resident a

order by Matrícula, Date;

DROP Table a;

DROP Field Date;

1.png

Qrishna
Master
Master

data_temp1:

load * inline  [

Matrícula,    Mês,      Local

1,                jan/15,    A

1,                fev/15,      A

1,              mar/15,    B

1,              abr/15,      B

2,              jan/15,      A

2,                fev/15,      B

2,              mar/15,      B

2,              abr/15,      B

];

data_temp:

NoConcatenate

load *

resident data_temp1

order by Mês,Matrícula;

drop table data_temp1;

data:

load *,

if(MêsFlag = 'Y' and Local<>previous(Local),1,0) as LocalChangeFlag;

load *,

if(Mês=previous(Mês) ,'Y','N') as MêsFlag

resident data_temp;

drop table data_temp;

drop fields

MêsFlag

from data;

See attached.

Not applicable
Author

So help me already , but without using the script can not make that comparison?

If I had to do for analysis sets help me , I say this cuz my qvw is ready and wanted to try to make this table without changing the script.