Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Théo123
Contributor III
Contributor III

Filtre complexe (et / ou)

Bonjour,

Voici ce que j'aimerai faire : rajouter les parenthèses ci-dessous

( [SRT] = {"val1","val2"} >*< [SOCTN] =  {"val3","val4"}  )

>+<

( [SRT] = {"val5","val6"} >*< [SOCTN] =  {"val7"}  )

Comment faire comprendre à Qlik le système de parenthèse dans ce cas ?

 

Labels (2)
2 Solutions

Accepted Solutions
marcus_sommer

I think it should look like:

{
(
 < 
[SRT] = {'val1', 'val2'} > * < [SOCTN] =  {'val3', 'val4'}  >)

+

(< [SRT] = {'val5', 'val6'} > * < [SOCTN] =  {'val7'}  >)
}

 

View solution in original post

Théo123
Contributor III
Contributor III
Author

Je vous remercie de votre réponse,

J'ai trouvé une solution à mon problème :

{<
[SRT] = {"val1","val2"},
    
    [SOCTN]={"val3,"val4","val5"}
>} 
        (count(
        {<
        [SOCTN] = {"val3,"val4"}
        >}
        distinct[SOCHN]))
        
        /
        
    count(distinct[SOCHN])  
 
@marcus_sommer Je te remercie pour toutes tes réponses !
   
  

View solution in original post

8 Replies
marcus_sommer

I think it should look like:

{
(
 < 
[SRT] = {'val1', 'val2'} > * < [SOCTN] =  {'val3', 'val4'}  >)

+

(< [SRT] = {'val5', 'val6'} > * < [SOCTN] =  {'val7'}  >)
}

 

Théo123
Contributor III
Contributor III
Author

Le + est toujours considéré comme un OU ?

 

marcus_sommer

Yes.

+ is OR and * is AND

Théo123
Contributor III
Contributor III
Author

Après de multiple tentative, je rencontre un problème, il semblerais que la syntaxe sois correcte mais le filtre ne s'applique pas !

{      
        (< [SRT] = {'val1'} >*< [SOCTN]={'val3','val4"} >)
        +
        (< [SRT] = {'val2'} >*< [SOCTN]={'val5'} >)
    } 
 
count(  {<  [SRT] = {'val3','val4'}  >}   distinct[SOCTN])
/
count(distinct[SOCTN])
        
marcus_sommer

The combination of inner and outer set analysis is not trivial. The announcement of this feature and the description within the help are creating an impression that they are replaceable to each other and simple in the usage but by reading it carefully there are some dependencies and exceptions mentioned - unfortunately without explaining it in detail.

If I remember correctly it states that by any kind of conflict the most inner set statement will win - overwriting the other set statements. I think what you have created is going in following direction:

{      
        (< [SRT] = {'val1'} >*< [SOCTN]={'val3','val4"} >)
        +
        (< [SRT] = {'val2'} >*< [SOCTN]={'val5'} >)
        *
        <  [SRT] = {'val3','val4'}  >
    } 
 
which shows that there is a conflict because [SRT] could have this value OR that values but not both at the same time. If it's applied within a single set statement it will lead to exclusions and maybe even to ZERO as result but by using it on the outer-side and the inner-side it's like a chain of selections - which means at first is the outer set statement = selection applied and then the inner one. If the inner selection doesn't fit to the outer set statement it replaced it.
 
Beside this the outer set statement isn't wrapped with brackets to a certain aggregation which means it will be applied of all following aggregations - also to this part: count(distinct[SOCTN]).
Théo123
Contributor III
Contributor III
Author

Je te remercie pour ta réponse complète.

Le fait que l'ensemble interne prime sur l'externe est ce que je souhaite.

Plus précisément, je souhaite créer un ensemble de donnée puis y appliquer un pourcentage donc en prenant qu'une partie de ces données d'où le :

count(  {<  [SOCTN] = {'val3','val4'}  >}   distinct[SOCTN]) (excusé mon erreur de frappe) (une partie des données)
/
compter(distinct[SOCTN]) (totale des données)
 
Enfin je souhaite effectivement appliquer cette partie :
{      
        (< [SRT] = {'val1'} >*< [SOCTN]={'val3','val4"} >)
        +
        (< [SRT] = {'val2'} >*< [SOCTN]={'val5'} >)
    } 
A l'entièreté de ma requête.
Cordialement
marcus_sommer

I'm not sure if it's suitable for your scenario but in several cases I could outsource some conditions and using it then as a boolean check against the base-aggregation. This may look like:

(count(  {<  [SOCTN] = {'val3','val4'}  >}   distinct[SOCTN])
/
count(distinct[SOCTN])
 
*
sign(count(
{      
        (< [SRT] = {'val1'} >*< [SOCTN]={'val3','val4"} >)
        +
        (< [SRT] = {'val2'} >*< [SOCTN]={'val5'} >)
    } 

[SOCTN]))

If this isn't working I suggest to create a table-box with the relevant fields + the relevant fields within list-boxes and then looking if the existing data-set provides the wanted selections. If it's not possible to align the appropriate rows there you couldn't apply it per set analysis.

Théo123
Contributor III
Contributor III
Author

Je vous remercie de votre réponse,

J'ai trouvé une solution à mon problème :

{<
[SRT] = {"val1","val2"},
    
    [SOCTN]={"val3,"val4","val5"}
>} 
        (count(
        {<
        [SOCTN] = {"val3,"val4"}
        >}
        distinct[SOCHN]))
        
        /
        
    count(distinct[SOCHN])  
 
@marcus_sommer Je te remercie pour toutes tes réponses !