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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Boucle IF

Est ce la boucle if ci dessous et correcte?

if(CodeArticle='52'or '151'or '153'or '223'or '224'or '251'or '252',QtéEmp/'4',

if(CodeArticle='1'or '2'or '4'or '8'or '9'or '10'or '12'or

'15'or '17'or '19'or '21'or '23'or '24'or '25'or

'26'or '28'or '30'or '32'or '34'or '38'or '40'or

'43'or '45'or '54'or '55'or '57'or '60'or '63'or

'126'or '127'or '152'or '239'or '240'or '246'or '250'or

'252'or '300'or '315'or '318'or '326'or '330',QtéEmp/'2',

if(CodeArticle='6'or '18'or '20'or '27'or '39'or '154'or '248',QtéEmp * '5',

if(CodeArticle='98'or '103'or '292'or '27',QtéEmp * '25',QtéEmp))))as Quantité,

Labels (1)
1 Solution

Accepted Solutions
rubenmarin
MVP
MVP

Hi Brahim, that's not correct, the correct syntaxis should be:

if(CodeArticle='52'or CodeArticle='151'.....

But you can avoid a lot of text and make it a bit clearer using match(): if a value is found, returs a number<>0, if it's not present returns zero (that is equal to FALSE)

If(Match(CodeArticle, '52', '151', '153', '223', '224', '251', '252'), QtéEmp/4....

Also when using number in divisons or multiplications you don't need to quote them.

Hope this helps!

View solution in original post

5 Replies
rubenmarin
MVP
MVP

Hi Brahim, that's not correct, the correct syntaxis should be:

if(CodeArticle='52'or CodeArticle='151'.....

But you can avoid a lot of text and make it a bit clearer using match(): if a value is found, returs a number<>0, if it's not present returns zero (that is equal to FALSE)

If(Match(CodeArticle, '52', '151', '153', '223', '224', '251', '252'), QtéEmp/4....

Also when using number in divisons or multiplications you don't need to quote them.

Hope this helps!

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Non.

IF() est une fonction qui n'acceptera pas des choses comme CodeArticle égale à 1 ou 2 ou 3 ou 4...

If faut le mettre comme ci

IF ((CodeArticle = 1) or (CodeArticle = 2) or ...)

ou encore mieuw:

IF (match(CodeArticle, '52', '151', '153', '223', '224', '251', '252'), QtéEmp / 4,

  IF (match... )) AS ...,

alexandros17
Partner - Champion III
Partner - Champion III

The syntax is wrong:

Use: if(CodeArticle='52'or CodeArticle='151'or CodeArticle='153'or CodeArticle='223'or .....

otherwise you can use

If(Wildmatch(CodeArticle,'52','151','153','223','224','251','252')>0, ....

let me know

Not applicable
Author

j'ai testé la boucle ci dessous elle retourne un résultat fausse.

if(Match(CodeArticle='52','151','153','223','224','251','252'),QtéEmp/'4',

if(Match(CodeArticle='1','2','4','8','9','10','12','15','17','19','21','23','24','25','26','28','30','32','34','38','40',

'43','45','54','55','57','60','63','126','127','152','239','240','246','250','252','300','315','318','326','330'),QtéEmp/'2',

if(Match(CodeArticle='6','18','20','27','39','154','248'),QtéEmp*'5',

if(Match(CodeArticle='98','103','292','27'),QtéEmp*'25',QtéEmp))))as Quantité

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Ce qui correspond aux attentes: le nombre 4 n'est pas la meme chose que le string '4' Changez tout les nombres entre guillemets. On peut pas calculer avec des strings