IIF and InStr

MonsterCR7

New Member
Joined
Jun 27, 2013
Messages
29
Hi All,
I am in query mode and I am trying to create a new column that will show an IIF statement to find certain words in the item number to return a result.
For example, If the item number contains the words “SER” then multiply the quantity times 20 to give a result of the cost of the labor hours.
The expression itself is working correctly, but it will only allow me to count values or records for the field.
How do I get it so that I can do a sum of the total cost of the labor hours?
 

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,825
Office Version
  1. 2019
Platform
  1. Windows
It should work. Can you post your SQL text?

Also, for what its worth, an easy solution that I also will implement is to:
  1. write the query with the IIF statement in it (don't use any aggregate functions here)
  2. write a query on the query you just wrote - this is where you sum up values using SUM().
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,709
Office Version
  1. 365
Platform
  1. Windows
SUM rather than COUNT
Note that there are a variety of Aggregate Functions to choose from. COUNT is just one of them. SUM is another option (as well as others).
 

Watch MrExcel Video

Forum statistics

Threads
1,127,936
Messages
5,627,714
Members
416,268
Latest member
zRGZgDNnmaPhepwviEou

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
Top