Hello,
I've been working on this question for several days and can't seem to get the answer, even though it seems straight forward.
I have a table in this format, which is essentially a funnel (the numbers indicate whether they got to that step):
ID | step.a | step.b | step.c | step.d |
---|---|---|---|---|
5467894 | a | b | c | 0 |
2465763 | 0 | 0 | 0 | 0 |
3438431 | a | b | c | d |
4574321 | a | b | 0 | 0 |
5498732 | 0 | 0 | 0 | 0 |
4543354 | a | b | c | 0 |
6543245 | a | 0 | 0 | 0 |
4651349 | a | 0 | 0 | 0 |
I then have a statement that says GREATEST(step.a,step.b,step.c,step.d)
, that gives me the highest step for each ID. This is what that output looks like:
ID | greatest |
---|---|
5467894 | c |
2465763 | 0 |
3438431 | d |
4574321 | b |
5498732 | 0 |
4543354 | c |
6543245 | a |
4651349 | a |
So the highest step ID 5467894
gets to is step.c
, 3438431
gets to step.d
, 4574321
gets to step.b
, etc.
What I need to show is the # of IDs that got to each step, because if an ID got to step.c
, then they got to step.a
and step.b
as well. If an ID got to step.d
, then they went through step.a
, step.b
, and step.c
.
Looking at my 'greatest' column above, I should have the following:
step | # of IDs |
---|---|
step.a | 6 |
step.b | 4 |
step.c | 2 |
step.d | 1 |
For my end result, I just need to show how many IDs are in each step. I am using DataGrip and QuickSight, and I can use either to calculate the column. I don't need to use the GREATEST() command, just an idea I had. Any help would be greatly appreciated. Thank you so much.