473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Using OR and IIF

Hi, I am doing a querry to calculate the customer satisfacation in my division and I need to know how many 5(always exceed) the employee received in one evaluation from a customer for all the questions. And there are 20 quetsions.
Here is my code that I wrote in the querry, but the count is not right, it gave me the total of 6, but the total suppose to be 20 because I have 5 of 5in performance_1, 5 of 5 in performance_2, 5 of 5 in performance_3, and 5 of 5 in performance_4.

Count 5:
Expand|Select|Wrap|Line Numbers
  1. Count(IIf([performance_1]=5 Or [Performance_2]=5 Or [Performance_3]=5 Or [Performance_4]=5 Or [Performance_5]=5 Or [Performance_6]=5 Or [Performance_7]=5 Or [Performance_8]=5 Or [Performance_9]=5 Or [Performance_10]=5 Or [Performance_11]=5 Or [Performance_12] Or [Performance_13]=5 Or [Performance_14]=5 Or [Professionalism]=5 Or [Confidentiality]=5 Or [Ownership]=5 Or [Accountability]=5 Or [Commitment]=5 Or [Communication]=5 Or [Telephone]=5 Or [Stewardship]=5 Or [Safety]=5 Or [Caring]=5 Or [Overall]=5,"yes"))
can somebody help please. thanks a lot and have a nice day.
Elaine
Oct 12 '07 #1
12 1691
nico5038
3,080 Expert 2GB
Hi, I am doing a querry to calculate the customer satisfacation in my division and I need to know how many 5(always exceed) the employee received in one evaluation from a customer for all the questions. And there are 20 quetsions.
Here is my code that I wrote in the querry, but the count is not right, it gave me the total of 6, but the total suppose to be 20 because I have 5 of 5in performance_1, 5 of 5 in performance_2, 5 of 5 in performance_3, and 5 of 5 in performance_4.

Count 5: Count(IIf([performance_1]=5 Or [Performance_2]=5 Or [Performance_3]=5 Or [Performance_4]=5 Or [Performance_5]=5 Or [Performance_6]=5 Or [Performance_7]=5 Or [Performance_8]=5 Or [Performance_9]=5 Or [Performance_10]=5 Or [Performance_11]=5 Or [Performance_12] Or [Performance_13]=5 Or [Performance_14]=5 Or [Professionalism]=5 Or [Confidentiality]=5 Or [Ownership]=5 Or [Accountability]=5 Or [Commitment]=5 Or [Communication]=5 Or [Telephone]=5 Or [Stewardship]=5 Or [Safety]=5 Or [Caring]=5 Or [Overall]=5,"yes"))
can somebody help please. thanks a lot and have a nice day.
Elaine
Hi Elaine,

Looks like your table isn't really "normalized", but this problem I guess is Nulls related.
When there's one of the fields holding a Null (nothing/unknown) value, the comparison won't work.
The solution will be to use the NZ() function like:
Count 5: Count(IIf(NZ([performance_1])=5 Or NZ([Performance_2])=5 Or NZ([Performance_3])=5 .... etc..

Getting the idea ?

Nic;o)
Oct 12 '07 #2
Scott Price
1,384 Expert 1GB
In addition to what Nico suggests, I think you are also expecting something different from the Count() function than what it does!

Count() only 'counts' the occurrences of a certain field according to your criteria. You sound like you're trying to accomplish more of a Sum() function.

Regards,
Scott
Oct 12 '07 #3
NeoPa
32,556 Expert Mod 16PB
Elaine,

As Scott says, I think we may need a bit of a rethink here.
Can you post your record layout for us (Table Meta-Data) and describe how it works (what it means). That way we can suggest a more appropriate way to process the data.

Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Oct 12 '07 #4
HI,
Here is my table data structure:
tblAdmin (for table Administration)
fields:
performance_1, type is number, byte
performance_2, type is number, byte,
performance_3, type is number, byte, etc.

For all these fields, the criteria is
5 is Always Exceeds
4 is Often Exceeds
3 is Consistently meets
2 is Sometimes meets
1 is Does not Meet
0 is N/A

I want to have a querry that count how many 5 "this person" has for all the customer evaluation questions re: performance_1, performance_, etc.
Thanks!
Oct 15 '07 #5
Scott Price
1,384 Expert 1GB
Hi Elaine,

A little further clarification, please. In your first post you sound as if you want to add the 5's together, to result in 20 (four 5's), while in your last post you sound as if you want to count how many 5's there are 4 (four 5's).

Which is it?

Count() returns how many 5's there are.

Sum() adds the 5's together.

Regards,
Scott
Oct 15 '07 #6
Scott,
Sorry for the confusion, I want to count how many 5's this employee received for his/her evaluation, not the sum.
for example. There are 20 questions in an evaluation form, this person completed 2 surveys for Jan, therefore, the total of question is 40. I want to coutn how many 5 she received. For example if she received 20. the rate for her "Always exceeds" will be 20/40.
Thanks!
Oct 15 '07 #7
Scott Price
1,384 Expert 1GB
Elaine,

Sorry to be the bearer of bad news, but I'm not sure that you can do it the way you are trying.

An alternative approach (although quite grotesque) is to use a number of queries, pulling the count of each category, which you will then sum in another query.

Here's an example of the first query:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblAdmin.EmployeeID, Count(tblAdmin.Performance_1) AS CountOfPerformance_1
  2. FROM tblAdmin
  3. GROUP BY tblAdmin.EmployeeID, tblAdmin.Performance_1
  4. HAVING (((tblAdmin.EmployeeID)=1) AND ((tblAdmin.Performance_1)="5"));
  5.  
Regards,
Scott
Oct 15 '07 #8
nico5038
3,080 Expert 2GB
Hmm, as stated before, your table should have been designed to hold one row per question like:
EmployeeA, Q1, Answer1
EmployeeA, Q2, Answer2
EmployeeA, Q3, Answer3
...etc...
EmployeeB, Q1, Answer1
...etc...

Having such a table will allow a GroupBy query counting the number of "5" values per user easily.

We can "fake" such a table by using a UNION query that's generating such a table and then we can use the UNION for the needed GroupBy.

The UNION will look like:
Expand|Select|Wrap|Line Numbers
  1. Select EmployeeID, "performance_1" as Question, [performance_1] as Answer from tblAdmin
  2. UNION
  3. Select EmployeeID, "performance_2" as Question, [performance_2] as Answer from tblAdmin
  4. UNION
  5. Select EmployeeID, "performance_3" as Question, [performance_3] as Answer from tblAdmin
  6. UNION
  7. ... etc ...
  8.  
Getting the idea ?

Nic;o)
Oct 15 '07 #9
NeoPa
32,556 Expert Mod 16PB
Elaine,

How many performance_ fields are there in the record?
Oct 16 '07 #10
Thanks for everyone's help.
There are about 25 questions per survey. I've tried Scott's way, it works. But since I have to use one column per performance question per category, and there are 6 categories re: 5, 4, 3, 2, 1 and 0; I am afraid that I might run out of of columns, but I'll try.
Thanks!

Elaine
Oct 23 '07 #11
nico5038
3,080 Expert 2GB
Hmm, would still want to ask you to try the UNION I proposed and after defining it for e.g. 5 questions use it in a crosstable query.
It will allow then one line for each question and for each category a column.
Also the pivot will be possible showing the six categories and the questions as columns.

Nic;o)
Oct 23 '07 #12
Thanks Nico for your help, I was able to complete the querry. It's working now.
Thanks!
Elaine
Oct 23 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
3
by: Mike L | last post by:
Should the command call "using" be before or after my namespace? **AFTER** namespace DataGridBrowser { using System; using System.Drawing; using System.Drawing.Drawing2D; using...
3
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
8
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
10
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL,...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.