Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
laurafinn
Contributor III
Contributor III

Set expression and IF not calculating as expected

Hi all,

I'm trying to count the number of loan applications where either a)  The loan end date is not populated (='1') and The status Reason = 'On Loan' 

OR 

b) The loan status = 'Active' and the expiry date of the loan is greater than the date of the reporting month.

The below 2 expressions work until I combine them:

i.e.

The below counts correctly on the basis of Scenario a:

Count ({$<[Loan End Date Flag]={'1'}>} {$<[Status Reason]={'On Loan'}>} [Loan Application ID]) 

The below counts correctly on the basis of Scenario b:

Count({$<[Loan Status 2]={'Active'}>} IF([Loan End Date] >[Max Day in Reporting Month], [Loan Application ID]))

However when I merge the two with the "+" Operator for "OR" the expression only appears to include the results of the second part of the expression (scenario b)

Count({$<[Loan End Date Flag]={'1'}>} {$<[Status Reason]={'On Loan'}> + <[Loan Status 2]={'Active'}>} IF([Loan End Date] >[Max Day in Reporting Month], [Loan Application ID]))

I feel like I'm close, can anyone help me spot what I'm missing? 

 

Labels (1)
1 Solution

Accepted Solutions
clementcouillaud
Partner - Contributor
Partner - Contributor

Hi @laurafinn ,

L'expression du scénario A me semble erronée.

La bonne expression pour le scénario  A n'est-elle pas plutôt :

Count ({$<[Loan End Date Flag]={'1'},[Status Reason]={'On Loan'}>} [Loan Application ID]) 

 

Dans ton cas, les scénarios ne sont-ils pas complémentaires ?

Si un enregistrement ne peut pas être dans le scénario A et B à la fois alors le plus simple consiste à sommer tes 2 expressions.

Count ({$<[Loan End Date Flag]={'1'},[Status Reason]={'On Loan'}>} [Loan Application ID]) 

+

Count({$<[Loan Status 2]={'Active'}>} IF([Loan End Date] >[Max Day in Reporting Month], [Loan Application ID]))

Sinon, pourrais-tu nous partager un extrait de ton jeu de données ?

Good luck !

Clément

View solution in original post

4 Replies
clementcouillaud
Partner - Contributor
Partner - Contributor

Hi @laurafinn ,

L'expression du scénario A me semble erronée.

La bonne expression pour le scénario  A n'est-elle pas plutôt :

Count ({$<[Loan End Date Flag]={'1'},[Status Reason]={'On Loan'}>} [Loan Application ID]) 

 

Dans ton cas, les scénarios ne sont-ils pas complémentaires ?

Si un enregistrement ne peut pas être dans le scénario A et B à la fois alors le plus simple consiste à sommer tes 2 expressions.

Count ({$<[Loan End Date Flag]={'1'},[Status Reason]={'On Loan'}>} [Loan Application ID]) 

+

Count({$<[Loan Status 2]={'Active'}>} IF([Loan End Date] >[Max Day in Reporting Month], [Loan Application ID]))

Sinon, pourrais-tu nous partager un extrait de ton jeu de données ?

Good luck !

Clément

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This is a case where I would use the advanced search {"=expr"} set like this:

Count(
{<[Loan Application ID] =
{"=([Loan Application ID]=1 and [Status Reason]='On Loan')
or ([Loan Status 2]='Active' and [Loan End Date] >[Max Day in Reporting Month])
"}>}
[Loan Application ID])

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

laurafinn
Contributor III
Contributor III
Author

This one didn't work however I wasn't familiar with the advanced search {"=expr"}  set, I'll explore that a little more!  Thank you for your help

laurafinn
Contributor III
Contributor III
Author

Thank you 🙂