Problem with statistic and COUNT

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Rem
Posts: 216
Joined: Wed Oct 03, 2007 8:58 am
Location: Sweden
Contact:

Problem with statistic and COUNT

Post by Rem »

We are struggling to get some statics to work the way we want them to.. (sorry if this is a stupid question but we have tried searching for relevant examples the entire day now ..)

We are running a process that collects installation and service jobs from a system and we are trying to COUNT it by user and save it to a statistic BO.

We have managed to get all the users out from the system and it show one row per user as we want it to do. But we cannot get the count right. It seems as it counts the first users jobs and put it on every user. If we change the sorting it will give us another number but always the same in every row.

It’s the two COUNT rows that we have problem with.

Any help is much appreciated!

The process look like this:

FIND RegularUser WHERE (RegularUser.LoginName<>'admin') ORDER BY RegularUser.LoginName DESC


CREATE Bokningsstatistik FOR EACH RegularUser WITH Bokningsstatistik.Tekniker=RegularUser.LoginName,
Bokningsstatistik.Installationer=COUNT Bokningar WHERE (Bokningar.Jobbtyp='Installation' AND Bokningar.Tekniker=RegularUser),
Bokningsstatistik.Service=COUNT Bokningar WHERE (Bokningar.Jobbtyp='Service' AND Bokningar.Tekniker=RegularUser),
Regards
Rune

Image
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Problem with statistic and COUNT

Post by tford »

One option is to break it into two processes:

Process_1:
FIND RegularUser WHERE (RegularUser.LoginName<>'admin') ORDER BY RegularUser.LoginName DESC IN BATCHES OF 1
Process_2

Process_2 (uses RegularUser as Input)
CREATE Bokningsstatistik WITH Bokningsstatistik.Tekniker=RegularUser.LoginName,
Bokningsstatistik.Installationer=COUNT Bokningar WHERE (Bokningar.Jobbtyp='Installation' AND Bokningar.Tekniker=RegularUser),
Bokningsstatistik.Service=COUNT Bokningar WHERE (Bokningar.Jobbtyp='Service' AND Bokningar.Tekniker=RegularUser),
Tom - V8.8 build 3137 - MySql / PostGres
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Problem with statistic and COUNT

Post by Jaymer »

Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Problem with statistic and COUNT

Post by aware_support »

In theory what you have there is correct and should work. So either there is no problem and the result of COUNT is correct (check your data!) or there is a bug.

If you break it up into two processes as suggested above and it works, then there is a bug in the system and we'll need to know
Aware IM Support Team
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: Problem with statistic and COUNT

Post by joben »

Me and Rem are working with the same business space and here is a late reply.

We tried tfords solution of using two processes, and it works exactly the way we wanted. Thanks!

If this is considered a bug we can provide a BSV.
Regards, Joakim

Image
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Problem with statistic and COUNT

Post by Jaymer »

I did this today, and it worked as expected.
I think if you would have had "IN BATCHES OF 1" on your original FIND, it would have worked.
Attachments
Create FOR EACH.png
Create FOR EACH.png (10.5 KiB) Viewed 6804 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply