Hi Sam,
Thanks for your suggestion on this. I had hoped you were going to suggest some implementation with the SQL 'Distinct' keyword with my Action Result to achieve this.
As to your suggested approach, I had already tried something like that. The problem is that not only do I need to count distinct customers, but I need to do this for multiple locations. Unfortuneatly I am one 'where condition' short in the 'loop through table' command. So, what I did was in that loop, I put in a standard conditional statement, and if the location identifier ( which I already had added to the Invoice Line table) matched the location I wanted, then I incremented my counter.
What I found was that when I did not select 'distinct' in the 'loop through table' command, this all worked fine and I was able to count the total number of customer records per location this way, as I would expect, but of course I counted the customers multiple times. When I set the loop to 'distinct Customer' , then the looping function failed in retrieving the 'location' value, and allocated all locations to the value of the first location alphabetically. Somehow the 'distinct' option cause the 'value from row' fetch of the location to be incorrect. I even tried doing a 'retrieve value from table with the current record ID' in the loop, which also failed. (although I think that was because it's not allowed in the loop).
I know this explanation seems convoluted, so I'll give an example to hopefully make it clearer. For the time period I was checking, I had four customers from two locations. Chronologically, they were Langford, Victoria, Langford, Langford. They all returned Langford as the location. Only when I changed the time period to only include the one record from Victoria, did I get that returned as the location.
One further bit of info. When I used the 'value from row' in the conditional command, it created an error if the 'loop through table' was distinct, but not if it wasn't I got around this by assinging an action result to the value in the loop, and using the action result in the conditional command. At first I thought this was a bug in the program, but maybe it's a feature if other fields are not available in 'distinct' mode, but then it should have failed on the action result assignment.
Any thoughts on how to proceed from here ?
Rolf