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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
choy
Contributor II
Contributor II

Create measure - count of the latest status

 

Hi All, 

I would like to seek your help to create a measure for waterfall chart, by count how many ID in each Stage (taken the latest/max date). Thank you.

ID Stage Date
1 A 2022-12-28T14:56:10
2 A 2022-12-07T11:22:27
2 B 2022-12-09T09:26:03
3 A 2022-10-24T12:01:08
3 B 2022-11-10T11:42:02
3 C 2022-11-24T10:05:36
     
     
Result    
Count Latest Stage in A Count Latest Stage in B Count Latest Stage in C
1 1 1
Labels (4)
1 Solution

Accepted Solutions
MayilVahanan

Suppose, if Date is not Date format, then try like below

LOAD *, Timestamp(Timestamp#(Date, 'YYYY-MM-DDTHH:mm:SS')) as Date1 INLINE [
ID, Stage, Date
1, A, 2022-12-28T14:56:10
2, A, 2022-12-07T11:22:27
2, B, 2022-12-09T09:26:03
3, A, 2022-10-24T12:01:08
3, B, 2022-11-10T11:42:02
3, C, 2022-11-24T10:05:36
];

And then, use this exp: =Count({<Stage={'A'}, Date1={"$(=Max({<Stage={'A'}>}Date1))"}>}DISTINCT ID)

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
Mark_Little
Luminary
Luminary

Hi,

Me personally would look at flagging the this in the script and it would give you a field to count in the set analysis.

LEFT JOIN (Table)

LOAD

ID,

MAX(Date),

1 as MaxFlag

Resident Table

Group By ID;

The you have the dimension on of stage and Count(MaxFlag)

 

choy
Contributor II
Contributor II
Author

Any other way  I can do it on measure directly?

MayilVahanan

Hi

Try like this

Count Latest Stage in A:

=Count({<Stage={'A'}, Date1={"$(=Max({<Stage={'A'}>}Date1))"}>}DISTINCT ID)

Similarly for remaining things

Hope it helps

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

Suppose, if Date is not Date format, then try like below

LOAD *, Timestamp(Timestamp#(Date, 'YYYY-MM-DDTHH:mm:SS')) as Date1 INLINE [
ID, Stage, Date
1, A, 2022-12-28T14:56:10
2, A, 2022-12-07T11:22:27
2, B, 2022-12-09T09:26:03
3, A, 2022-10-24T12:01:08
3, B, 2022-11-10T11:42:02
3, C, 2022-11-24T10:05:36
];

And then, use this exp: =Count({<Stage={'A'}, Date1={"$(=Max({<Stage={'A'}>}Date1))"}>}DISTINCT ID)

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

I followed your solution but the result is 0 ?