ms access - nested if statement in query -


(please excuse didn't use aliases). query output "none" if 3rd qrtr sales equals 4th quarter sales, output saying "up" when equal each other. please me correct code

trend: iif([qryquarterlycustomersales3rdquarter_final] .[3rd qrtr sls]=[qryquarterlycustomersales4thquarter_final] .[4th qrtr sls],"none", iif([qryquarterlycustomersales3rdquarter_final] .[3rd qrtr sls]>[qryquarterlycustomersales4thquarter_final] .[4th qrtr sls],"down","up")) 

are sure 2 values same?
written there appears slight mistake in inner iif statement, doesn't explain results you're getting.

pseudocode helps me understand how these expressions work:

if q3 = q4     "none" else*     if q3 > q4         "up"     else*         "down" 

*note else implied; not legal syntax here

making few changes possible, should work expect to:

trend: iif([qryquarterlycustomersales3rdquarter_final] .[3rd qrtr sls] = [qryquarterlycustomersales4thquarter_final] .[4th qrtr sls],"none", iif([qryquarterlycustomersales3rdquarter_final] .[3rd qrtr sls] > [qryquarterlycustomersales4thquarter_final] .[4th qrtr sls],"up","down")) # <- these final 2 args should switched 

documentation:

syntax

iif(expr, truepart, falsepart)

the iif function syntax has these arguments:

argument description expr required. expression want evaluate. truepart required. value or expression returned if expr true. falsepart required. value or expression returned if expr false.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -