Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Where Contract Start = Contract End +1

Hi All,

I have 3 fields ID, CONTRACT START YEARMONTH and CONTRACT END YEARMONTH.

I want to count the Distinct IDs where CONTRACT START YEARMONTH = the Selected value for CONTRACT END YEARMONTH.

In short it counts IDs where the Contract has been renewed.

I can get the values ok when I specify a specific yearmonth but I'd prefer if it was based on the selection itself:

COUNT(DISTINCT{<CONTRACT_START_DTTM_YEARMONTH ={'2018 Jan'}, CONTRACT_END_DTTM_YEARMONTH = {'2017 Dec'}>}ID

Cheers,

5 Replies
Anonymous
Not applicable
Author

Amendment:

I want to count the Distinct IDs where CONTRACT START YEARMONTH = the Selected value for CONTRACT END YEARMONTH+1

jyothish8807
Master II
Master II

Hi Tim,

Try like this:

vConEnd= date(addmonths(GetFieldSelections([CONTRACT END YEARMONTH]),1),'YYYY MMM')


COUNT(DISTINCT{<CONTRACT_START_DTTM_YEARMONTH ={'2018 Jan'}, CONTRACT_END_DTTM_YEARMONTH = {'$('vConEnd)'}>}ID)

Best Regards,
KC
sunny_talwar

When you say +1, do you mean one day or 1 month? Also, it might help to see any an example data set and the output you expect to see from it

Anonymous
Not applicable
Author

Hi Sunny,

+1 should be one month, sample data below:

IDCONTRACT START YEARMONTHCONTRACT END YEARMONTH
12015 Jan2015 Dec
12016 Jan2016 Dec
12017 Jan2017 Dec
12018 Jan2018 Dec
22016 Jan2016 Dec
22017 Jan2017 Dec
32017 Jan2017 Dec
42017 Jan2017 Dec
52017 Jan2017 Dec
52018 Jan2018 Dec
62016 Jan2016 Dec
62017 Jan2017 Dec
62018 Jan2018 Dec
72018 Jan2018 Dec
82018 Jan2018 Dec
92016 Jan2016 Dec
92017 Jan2017 Dec
92018 Jan2018 Dec
102015 Jan2015 Dec
102016 Jan2016 Dec

  If I wanted to count the Number of renewals for contracts that Ended 2017 Dec. I would be looking for sites with this end date but with a further Contract start date of 2018 Jan .  In the example above it should return IDs, 1,5,6 9 .

As I mentioned in my initial post, COUNT(DISTINCT{<CONTRACT_START_DTTM_YEARMONTH ={'2018 Jan'}, CONTRACT_END_DTTM_YEARMONTH = {'2017 Dec'}>}ID) returns this for me but I would like my expression to be dependent on the Contract End Date selected by the user.

Thanks,

Tim

sunny_talwar

Try this

=Count(DISTINCT{<ID = P({<[CONTRACT START YEARMONTH] = {"$(=Date(MonthStart(Max([CONTRACT END YEARMONTH]), 1), 'YYYY MMM'))"}, [CONTRACT END YEARMONTH]>})*P({<[CONTRACT END YEARMONTH] = {"$(=Date(Max([CONTRACT END YEARMONTH]), 'YYYY MMM'))"}>}), [CONTRACT END YEARMONTH]>}ID)

Capture.PNG