Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculation Logic

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 YearMetric2013201420152016
2013Original Donors25,000---
Original Sustainers25,00010,0007,0004,000
YOY Retention-40%70%57%
Base Retention-40%28%16%
2014Original Donors-40,000--
Original Sustainers-40,00015,0002,000
YOY Retention--37.5%13.3%
Base Retention--37.5%5%
2015Original Donors--65,000-
Original Sustainers--65,0005,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

15 Replies
Anonymous
Not applicable
Author

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?

effinty2112
Master
Master

Hi Weston,

Try this for your expression:

if(Before(count(DISTINCT DonorID))>0,

Count(DISTINCT DonorID)-Before(count(DISTINCT DonorID),ColumnNo()-RowNo()))

Cheers

Andrew

Anonymous
Not applicable
Author

I actually need the Percent Retention not the change...my mistake.

effinty2112
Master
Master

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

Anonymous
Not applicable
Author

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.

effinty2112
Master
Master

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