MS Query help needed

Reshaw

Board Regular
Joined
Mar 2, 2011
Messages
53
Morning everyone

I currently have a sheet which calculates our customers' spend sorted by customer then by rep then week.

This bit is working fine, I use an MS Query to fetch in all the jobs we have done so far this year. This list is getting a bit large already (30000+ rows) and I can shrink this a bit by omitting several house account codes an one particular customer which is large and we measure seperately.

I tried to use the wizard within MS Query to get it to list all job so far this year without a few account codes.

The code looks like this:

SELECT
WALKER_HAJobFile.JobNumber,​
WALKER_HAJobFile.Account,​
WALKER_HAJobFile.Volume,​
WALKER_HAJobFile.Quantity,​
WALKER_HAJobFile.Value1,​
WALKER_HAJobFile.DelDate,​
WALKER_HAJobFile.JobCancelled,​
WALKER_HAJobFile.DelPostCode​
FROM
DBA.WALKER_HAJobFile WALKER_HAJobFile​
WHERE
(WALKER_HAJobFile.DelDate Between {d '2013-01-01'} And {d '2013-12-31'} )​
AND
(WALKER_HAJobFile.JobCancelled='N')​
AND
(​
(WALKER_HAJobFile.Account<>'BABY') OR​
(WALKER_HAJobFile.Account<>'EVERB') OR​
(WALKER_HAJobFile.Account<>'ROLF') OR​
(WALKER_HAJobFile.Account<>'ZZPAL') OR​
(WALKER_HAJobFile.Account<>'GWT')​
)​
ORDER BY WALKER_HAJobFile.DelDate



However it still lists jobs for the accounts GWT, ZZPAL and so on. It's as if excel is ignoring the last part of the Where statement, or else I've got my logic wrong.

Have I got my AND's and OR's mixed up?

Thanks in advance
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Thanks Firefly, you are absolutely correct, bit of a stupid error on my part. :oops:

Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,702
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top