Search code examples
arraysif-statementgoogle-sheets-formulagoogle-query-languagenested-if

Combining Query and Conditional Statement in Google Spreadsheets


Regardiung the function below, I want this line AND P < '"&B5&"' to be applied everytime but not when B3="446". I'm not sure how to insert this condition in the query fnction.

=IFERROR(QUERY(BDD!A1:T2972;
"SELECT A,R,B,C,D,E,S,I,T,P,J,K,L 
WHERE A IS NOT NULL 
AND P < '"&B5&"' 
AND 1=1 "&IF(B2="XXXX";"";" AND LOWER(J) = LOWER('"&B2&"') ")&IF(B3="0c";"";" AND LOWER(S) = LOWER('"&B3&"') 
AND NOT(LOWER(J)='PERM' AND T='"&B3&"')
AND I = 'ADMI'
ORDER BY A , P")
;0);"PAS DE RÉSULTAT")

Solution

  • try to replace:

    AND P < '"&B5&"'
    

    with:

    "&IF(B3*1=446; "1=1"; "AND P < '"&B5&"'")&"