query question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a query that contains name, salary, and position info (Full
time or part-time) but I need to add a new column that shows the following
info:
If position value equals 1 (FT), then multiply salary by .15 and display in
new column. If position value equals 2, then display salary without change.

How and where do I type thisn expression?
 
In design view of your query add this as a new column --
Multiplier: IIf([Position] = 1,[Salary] * .15, [Salary])

Seems like you want this --
Multiplier: IIf([Position] = 1,[Salary] * .15 + [Salary], [Salary])
 
Or:
Multiplier: IIf([Position] = 1,[Salary] * 1.15, [Salary])

KARL DEWEY said:
In design view of your query add this as a new column --
Multiplier: IIf([Position] = 1,[Salary] * .15, [Salary])

Seems like you want this --
Multiplier: IIf([Position] = 1,[Salary] * .15 + [Salary], [Salary])

Wendy said:
I have created a query that contains name, salary, and position info (Full
time or part-time) but I need to add a new column that shows the following
info:
If position value equals 1 (FT), then multiply salary by .15 and display in
new column. If position value equals 2, then display salary without change.

How and where do I type thisn expression?
 
Wendy:
I am really novice at this so I am not sure the help I can be, but I know
where to put the criteria in your query you want. If you have added a column
for the answer to be placed, do so in your table.

Then go to query and open in design view, and enter your expression in the
criteria area under the heading of the column you created.

Now, the expression is where my experience is really foggy... I suspect the
expression may look something like this (not knowing how your DB is set up or
your column names you have it is hard to give explicit advise):

IIf([PositionValue] = "FT", [salary]*.15, =[sal]")
Again, this is not my area, but if you think of the logic behind yes/no
expressions it is---- if value = true (in your case FullTime), do true (x
sal by.15), else =salary???? If this doesn't work, sorry I tried!
 
Sorry, but that should not go in the table. It qualifies as a calculated
value. No calculated value should ever go in a table. Karl's response would
be the correct way to do it. The only difference between his and mine is how
it is written. They evaluate to the same thing.

Jcraig713 said:
Wendy:
I am really novice at this so I am not sure the help I can be, but I know
where to put the criteria in your query you want. If you have added a column
for the answer to be placed, do so in your table.

Then go to query and open in design view, and enter your expression in the
criteria area under the heading of the column you created.

Now, the expression is where my experience is really foggy... I suspect the
expression may look something like this (not knowing how your DB is set up or
your column names you have it is hard to give explicit advise):

IIf([PositionValue] = "FT", [salary]*.15, =[sal]")
Again, this is not my area, but if you think of the logic behind yes/no
expressions it is---- if value = true (in your case FullTime), do true (x
sal by.15), else =salary???? If this doesn't work, sorry I tried!



Wendy said:
I have created a query that contains name, salary, and position info (Full
time or part-time) but I need to add a new column that shows the following
info:
If position value equals 1 (FT), then multiply salary by .15 and display in
new column. If position value equals 2, then display salary without change.

How and where do I type thisn expression?
 
Now I disclaim that I am a novice... :o) So instead of adding a column for
the answer or result, would one just put the expression in the salary
criteria in the query? I only ask as I often have the same issue... where
to put the expression and how to do it.


Klatuu said:
Sorry, but that should not go in the table. It qualifies as a calculated
value. No calculated value should ever go in a table. Karl's response would
be the correct way to do it. The only difference between his and mine is how
it is written. They evaluate to the same thing.

Jcraig713 said:
Wendy:
I am really novice at this so I am not sure the help I can be, but I know
where to put the criteria in your query you want. If you have added a column
for the answer to be placed, do so in your table.

Then go to query and open in design view, and enter your expression in the
criteria area under the heading of the column you created.

Now, the expression is where my experience is really foggy... I suspect the
expression may look something like this (not knowing how your DB is set up or
your column names you have it is hard to give explicit advise):

IIf([PositionValue] = "FT", [salary]*.15, =[sal]")
Again, this is not my area, but if you think of the logic behind yes/no
expressions it is---- if value = true (in your case FullTime), do true (x
sal by.15), else =salary???? If this doesn't work, sorry I tried!



Wendy said:
I have created a query that contains name, salary, and position info (Full
time or part-time) but I need to add a new column that shows the following
info:
If position value equals 1 (FT), then multiply salary by .15 and display in
new column. If position value equals 2, then display salary without change.

How and where do I type thisn expression?
 
No it is not criteria but is a calculated field. Add a field name like
Multiplier followed by a colon and then your calculation.

Jcraig713 said:
Now I disclaim that I am a novice... :o) So instead of adding a column for
the answer or result, would one just put the expression in the salary
criteria in the query? I only ask as I often have the same issue... where
to put the expression and how to do it.


Klatuu said:
Sorry, but that should not go in the table. It qualifies as a calculated
value. No calculated value should ever go in a table. Karl's response would
be the correct way to do it. The only difference between his and mine is how
it is written. They evaluate to the same thing.

Jcraig713 said:
Wendy:
I am really novice at this so I am not sure the help I can be, but I know
where to put the criteria in your query you want. If you have added a column
for the answer to be placed, do so in your table.

Then go to query and open in design view, and enter your expression in the
criteria area under the heading of the column you created.

Now, the expression is where my experience is really foggy... I suspect the
expression may look something like this (not knowing how your DB is set up or
your column names you have it is hard to give explicit advise):

IIf([PositionValue] = "FT", [salary]*.15, =[sal]")
Again, this is not my area, but if you think of the logic behind yes/no
expressions it is---- if value = true (in your case FullTime), do true (x
sal by.15), else =salary???? If this doesn't work, sorry I tried!



:

I have created a query that contains name, salary, and position info (Full
time or part-time) but I need to add a new column that shows the following
info:
If position value equals 1 (FT), then multiply salary by .15 and display in
new column. If position value equals 2, then display salary without change.

How and where do I type thisn expression?
 
KARL is correct. I know you stated you are a novice, that is why I
responded, so you wont make a classic mistake of putting things in tables
that don't belong.
What he is saying is, if you want a calculated field in a query, where you
would normally put the field name, you give it your own name followed by a
colon, then the calculation. So in this case, in the field row of the query
builder it would be:

Multiplier: IIf([PositionValue] = "FT", [salary] * 1.15, [salary]")

Then when you run the query, you will see a column with the header saying
Multiplier and the result of the calculation for eac row. This is always the
way to do calculated values. One of the basic rules of database design is
"never carry a calculated value in a table"


Jcraig713 said:
Now I disclaim that I am a novice... :o) So instead of adding a column for
the answer or result, would one just put the expression in the salary
criteria in the query? I only ask as I often have the same issue... where
to put the expression and how to do it.


Klatuu said:
Sorry, but that should not go in the table. It qualifies as a calculated
value. No calculated value should ever go in a table. Karl's response would
be the correct way to do it. The only difference between his and mine is how
it is written. They evaluate to the same thing.

Jcraig713 said:
Wendy:
I am really novice at this so I am not sure the help I can be, but I know
where to put the criteria in your query you want. If you have added a column
for the answer to be placed, do so in your table.

Then go to query and open in design view, and enter your expression in the
criteria area under the heading of the column you created.

Now, the expression is where my experience is really foggy... I suspect the
expression may look something like this (not knowing how your DB is set up or
your column names you have it is hard to give explicit advise):

IIf([PositionValue] = "FT", [salary]*.15, =[sal]")
Again, this is not my area, but if you think of the logic behind yes/no
expressions it is---- if value = true (in your case FullTime), do true (x
sal by.15), else =salary???? If this doesn't work, sorry I tried!



:

I have created a query that contains name, salary, and position info (Full
time or part-time) but I need to add a new column that shows the following
info:
If position value equals 1 (FT), then multiply salary by .15 and display in
new column. If position value equals 2, then display salary without change.

How and where do I type thisn expression?
 
Back
Top