All
If i have several customers starting with e.g. 'RAN', how would you use a wildcard to count them all, the query below keeps giving me a count rather than a sum??
=Sum(IIf([Customer]="RAN*",[Quantity],1))
All
If i have several customers starting with e.g. 'RAN', how would you use a wildcard to count them all, the query below keeps giving me a count rather than a sum??
=Sum(IIf([Customer]="RAN*",[Quantity],1))
Don't use = with wildcards, use LIKE
=Sum(IIf([Customer] LIKE "RAN*",[Quantity],1))
plus, use DSum to sum over a field in a domain. Your posted expression probably results in 1 for each record? I would have attempted an example expression, but I'm not sure what the table/query name would be, or if the field is [Quantity] or something else.
Last edited by Micron; 05-19-2018 at 01:49 PM. Reason: clarification
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Hi
Ive tried using DSum as below but i get an error
=DSum(IIf([Customer] Like "RAN*",[Quantity],1))
'The expression you entered has a function containing the wrong number of arguments'
Also to COUNT the instances could you substitute DSum with COUNT??
Domain functions like DSum have three arguments: Field, Table or query, filter condition
The condition is optional but the other two are required
Yes, that's what I meant byand not knowing the name of the query or table. I should have posted a link to the function, or an example of it. Not knowing the field or domain name, I opted for the lazy way out.use DSum to sum over a field in a domain
The query name is 'CycleCountSelection' which opens a report.
I need to do 2 things....
Count the number of instances in column 'Customer' beginning with "RAN*" (Textbox1)
Sum the Column 'Quantity' when the customer begins with "RAN*" (Textbox2)
So if i had 2 records each with a quantity of 10 - Textbox1 would equal 2 and Textbox2 would equal 20
Hope that makes sense
Textbox1: =Sum(IIf([Customer] Like "RAN*", 1, 0))
or =Count(IIf([Customer] Like "RAN*", 1, Null))
Textbox2: =Sum(IIf([Customer] Like "RAN*", [Quantity], 0))
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.