Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
jbakerstull
Creator
Creator

Negative results

The formula below returns the number of days that are within a reporting period. The formula captures all persons.

Sum(Num(IF([Exit Date Adjusted]>'3/31/2019','3/31/2019',[Exit Date]))-
Num(IF([Entry Date]<'01/01/2019','01/01/2019',[Entry Date])))

If my data set, data element [Household Head of Household] identifies head of households by [Household Head of Household]='Yes'

My understanding is that I'm unable to use a set expression because of use of If statements. 

I'm trying to incorporate [Household Head of Household]='Yes' data element into formula as below.

Sum(Num(IF([Exit Date Adjusted]>'3/31/2019','3/31/2019',[Exit Date]))-
Num(IF([Entry Date]<'01/01/2019','01/01/2019',[Entry Date]))
And[Household Head of Household]='Yes')

 

The result is negative days. My goal is to count number of days for [Household Head of Household]='Yes'. 

Thans

3 Replies
jbakerstull
Creator
Creator
Author

the formula below returns the same result but just in a set expression

 

=Sum({$<[Entry Date]={'<=$(=EndDate)'},[Exit Date Adjusted]={'>=$(=StartDate)'}>}[Household Head of Household]='Yes')

JordyWegman
Partner - Master
Partner - Master

Hi,

I think you should count the days. But in your formula, you are missing the thing that you are counting/summing. In the part I've added the household to the set analysis.  Fill in WhatDoYouWantToCount the field that you want to count.

Count({$<[Entry Date]={'<=$(=EndDate)'},[Exit Date Adjusted]={'>=$(=StartDate)'}, [Household Head of Household]= {'Yes'} >} [WhatDoYouWantToCount])

Jordy

Climber

Work smarter, not harder
jbakerstull
Creator
Creator
Author

I don't work in Qlik everyday, I'm self teaching myself. Which is hard because I can just ask someone for guidance. Does  the set expression always have to include a data element at the end to return a value ? 

Formula below is what I'm using to sum all days within report period. 

Sum(Num(IF([Exit Date Adjusted]>[EndDate],[EndDate],Date([Exit Date]))-
Num(IF([Entry Date]<StartDate,StartDate,Date([Entry Date])))))

 

I tried the formula and the result return an 11 when using [Entry Date]. The total number of shelter units is 383

 

Client IdShelter UnitsEntry DateExit DateHousehold Head of Household
85128910/9/20184/26/2019Yes
50250293/2/20195/6/2019Yes
60180442/15/20194/3/2019Yes
6342803/31/20194/4/2019Yes
70581382/15/20193/25/2019Yes
7058123/29/20195/28/2019Yes
100999831/7/20194/29/2019Yes
121531128/12/20181/13/2019Yes
13037522/1/20192/3/2019Yes
148816761/14/20195/1/2019Yes
16720382/13/20192/21/2019Yes

 

 

I'm thinking that formula below needs to converted into a variable in order to count total shelter units. 

Sum(Num(IF([Exit Date Adjusted]>[EndDate],[EndDate],Date([Exit Date]))-
Num(IF([Entry Date]<StartDate,StartDate,Date([Entry Date])))))