Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello QC!
Need some help with a Pivot Table today. My logic/SQL is a bit rusty (haven't done development in a while) so I'd appreciate the help tremendously.
I am creating a table that has 11 different metrics/calculations grouped by years (2013-2016, see column 1), and also measured across years (need years on horizontal and vertical rows). The calculations is to provide metrics about Donor Data for our non-profit for the last 4 years.
There are two metrics that are needed for most of the others that I need help calculating.
1) Original Donors - [OD] - The number of Donors whose first gift was given in 2013 (or selected [First Gift Year]).
2) Original Sustainers [OS] - The number of Donors that gave in a year (2013-2016) that became first time Donors in 2013 ([OD]). So in this case the value for [OS] in 2013 will equal the value for [OD] in 2013; Same for other years.
Any thoughts on how to write these Count/If statements?
It hopefully will look something like this:
First Gift Year | Metric | 2013 | 2014 | 2015 | 2016 |
---|---|---|---|---|---|
2013 | Original Donors | 25,000 | - | - | - |
Original Sustainers | 25,000 | 10,000 | 7,000 | 4,000 | |
YOY Retention | - | 40% | 70% | 57% | |
Base Retention | - | 40% | 28% | 16% | |
2014 | Original Donors | - | 40,000 | - | - |
Original Sustainers | - | 40,000 | 15,000 | 2,000 | |
YOY Retention | - | - | 37.5% | 13.3% | |
Base Retention | - | - | 37.5% | 5% | |
2015 | Original Donors | - | - | 65,000 | - |
Original Sustainers | - | - | 65,000 | 5,000 |
As usual, if this isn't clear, or you need more info, let me know. My SQL needs polishing, so any help is appreciated!
Thanks in advance to you Qlik Wizards!
-misterk
Thanks for the great stuff.
What about calculating Base Year Retention/Change?
So using the First Year instead of the Previous Year? I tried using first, but once I get to 2014, it still grabs 2013.
Does that make sense?
Hi Weston,
Try this for your expression:
if(Before(count(DISTINCT DonorID))>0,
Count(DISTINCT DonorID)-Before(count(DISTINCT DonorID),ColumnNo()-RowNo()))
Cheers
Andrew
I actually need the Percent Retention not the change...my mistake.
We're getting there Weston, we're getting there!
Try:
if(Before(count(DISTINCT DonorID))>0,
Count(DISTINCT DonorID)/Before(count(DISTINCT DonorID),ColumnNo()-RowNo()))
Cheers
Andrew
Beautiful. Works great,
Do you mind explaining how the before uses the col/row functions? It's a bit unclear even after reading some of the documentation on it.
Hi Weston,
Very happy it's working for you. Will try to explain but please forgive me if I don't reply until tomorrow, it's 10:40 pm for me and I need my beauty sleep.
all the best
Andrew