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: 
Applicable88
Creator III
Creator III

Cut out Dataset with a calculated dimension

Hello,

I have the following table: 

 

QueueNo.ActionNo.ActionNameStartFinished
11115000Start08:0008:05
11115001Moving08:0508:10
11115002Parking08:1008:12
11115003Moving08:1208:29
11115004Success08:2908:30
22225100Start09:0009:00
22225101Moving09:0109:10
22225102Failed09:1009:10

 

I want a calculated dimension where I only see the first and last actionNo of a QueuNo. I tried different methods to cut out the sub-actions. but I either get complete null or nothing happens. 

Hope someone has an idea. 

Best. 

1 Solution

Accepted Solutions
MayilVahanan

Hi @Applicable88 

Try like below

=Aggr(Only({<ActionNo. = {$(=Concat(Aggr(Min(ActionNo.),QueueNo.),',')),$(=Concat(Aggr(Max(ActionNo.),QueueNo.),','))}>}ActionNo.), ActionNo., QueueNo.)

MayilVahanan_1-1604916917636.png

 


But, you can create a flag in script for better performance

T2:
LOAD *, If(QueueNo. <> Peek(QueueNo.), 1, Peek(Row)+1) as Row INLINE [
QueueNo., ActionNo., ActionName, Start, Finished
1111, 5000, Start, 08:00, 08:05
1111, 5001, Moving, 08:05, 08:10
1111, 5002, Parking, 08:10, 08:12
1111, 5003, Moving, 08:12, 08:29
1111, 5004, Success, 08:29, 08:30
2222, 5100, Start, 09:00, 09:00
2222, 5101, Moving, 09:01, 09:10
2222, 5102, Failed, 09:10, 09:10
];

Temp:
LOAD QueueNo., Min(Row) as Row Resident T2 group by QueueNo.;
LOAD QueueNo., Max(Row) as Row Resident T2 group by QueueNo.;

Join(T2)
LOAD *, 1 as flag Resident Temp;

DROP Table Temp;

Front end: =Aggr(Only({<flag ={1}>}ActionNo.), ActionNo.)

MayilVahanan_0-1604916888342.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

5 Replies
Taoufiq_Zarra

@Applicable88  if I understood correctly first and last correspond to Start Success or Failed, you can try below

in calculated dimension for ActionNo :

=aggr(Only({<ActionName={'Start','Success','Failed'}>}[ActionNo.]),[ActionNo.])

 

the output from table :

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Applicable88
Creator III
Creator III
Author

Hi  @Taoufiq_Zarra  thanks,

there is much more ActionNames....but with your aggregation it come close to what I want. 

Is there a possiblity using a aggregation towards the Min Startedtime and the MaxFinishedtime of the Same QueueNo?

Means : Return only the first and last action of a queue, but nothing in between.  Otherwise there are plenty of ActionNames I have to include or exclude.

I hope you have an idea. 

Thx! 

Taoufiq_Zarra

@Applicable88  can you give an example , and expected output ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Applicable88
Creator III
Creator III
Author

  I show you with before/after:

Before:

QueueNo.

ActionNo.

ActionName

Start

Finished

1111

5000

Start

08:00

08:05

1111

5001

Moving

08:05

08:10

1111

5002

Parking

08:10

08:12

1111

5003

Moving

08:12

08:29

1111

5004

Success

08:29

08:30

2222

5100

Start

09:00

09:00

2222

5101

Moving

09:01

09:10

2222

5102

Failed

09:10

09:10

 

After:

1111

5000

Start

08:00

08:05

1111

5004

Success

08:29

08:30

2222

5100

Start

09:00

09:00

2222

5102

Failed

09:10

09:10

 

So I mean to use the time to filter instead of the Actions.

MayilVahanan

Hi @Applicable88 

Try like below

=Aggr(Only({<ActionNo. = {$(=Concat(Aggr(Min(ActionNo.),QueueNo.),',')),$(=Concat(Aggr(Max(ActionNo.),QueueNo.),','))}>}ActionNo.), ActionNo., QueueNo.)

MayilVahanan_1-1604916917636.png

 


But, you can create a flag in script for better performance

T2:
LOAD *, If(QueueNo. <> Peek(QueueNo.), 1, Peek(Row)+1) as Row INLINE [
QueueNo., ActionNo., ActionName, Start, Finished
1111, 5000, Start, 08:00, 08:05
1111, 5001, Moving, 08:05, 08:10
1111, 5002, Parking, 08:10, 08:12
1111, 5003, Moving, 08:12, 08:29
1111, 5004, Success, 08:29, 08:30
2222, 5100, Start, 09:00, 09:00
2222, 5101, Moving, 09:01, 09:10
2222, 5102, Failed, 09:10, 09:10
];

Temp:
LOAD QueueNo., Min(Row) as Row Resident T2 group by QueueNo.;
LOAD QueueNo., Max(Row) as Row Resident T2 group by QueueNo.;

Join(T2)
LOAD *, 1 as flag Resident Temp;

DROP Table Temp;

Front end: =Aggr(Only({<flag ={1}>}ActionNo.), ActionNo.)

MayilVahanan_0-1604916888342.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.