CASE Statement order of precedence
679919Feb 16 2009 — edited Aug 8 2012The question i have is in regards to the CASE statement.
If i have the following CASE statement in a calculation, and use the calculation to populate the column header, it returns 2 columns, one for 'Mexico' and one for 'Exclude' - That is good
Statement 1:
CASE WHEN ( "Customers (Sales History)".Country = 'MX' )
THEN 'Mexico'
ELSE 'Exclude'
END
So i have sucessfully extracted out sales from Mexico, now i want break those sales into 2 categories, 'Primary' and 'Secondary'. If i use the below case statement, I was expecting to get 3 column headers, one for 'Primary' one for 'Secondary' and one for 'Exclude', but instead I only get 1 column header for exclude. Im sure it has something to do with order of precedence, but could someone explain the logic of why discover handles it this way, and how to get around it?
Statement 2:
CASE WHEN ( "Customers (Sales History)".Country = 'MX' )
THEN
CASE WHEN ( Item Groups.Sales Type Id <> 3)
THEN 'Primary'
ELSE 'Secondary'
END
ELSE 'Exclude'
END
As a side note, if i use statement 2 and set a condition "Statement 2 <> 'Exclude'" , the result will be the columns 'Primary' & 'Secondary'
Thanks
Chris