If you are unable to create a new account, please email bspsoftware@techdata.com

Author Topic: How can I achieve this? - prevent double counting  (Read 5323 times)

satiyabaazi

  • Guest
How can I achieve this? - prevent double counting
« on: 04 Nov 2016 12:29:36 pm »
I have this in my report -
Field 0   Field 1   Field 2   Field 3
Emp 1   a           x1            x2
Emp 1   b           x               x2
Emp 1   c           x1             x2
Emp 1   d           x1            x2
Emp 2   e           y1            y2
Emp 2   f           y1            y2
Emp 2   g           y1            y2

I want to be able to achieve this -

Field 0   Field 1   Field 2   Field 3   Field 4
                a           x1           x2   
                b           x1           x2   
                c           x1           x2   
                d           x1           x2   
Emp 1   a+b+c+d   x1           x2   (x2-x1-(a+b+c+d))
                e           y1           y2   
                f           y1           y2   
Emp 2   e+f+g   y1           y2   (y2-y1 + (e+f+g))

The problem I'm facing is that in my summary row - it adds up (x2-x1) multiple times and I can't figure out a formula that will take into account the count of rows and divide the (x2-x1)/count(number of rows for unique Emp) and then subtract the (a+b+c+d) from it. Any help will be appreciated. Thanks guys!

Offline stan.parker

  • Full Member
  • ***
  • Join Date: Oct 2016
  • Posts: 29
  • Forum Citizenship: +0/-0
Re: How can I achieve this? - prevent double counting
« Reply #1 on: 04 Nov 2016 12:38:27 pm »
Can you give more information about the data? Do all of the fields reside in the same query subject or do Field 2 and Field 3 company from separate query subjects?

satiyabaazi

  • Guest
Re: How can I achieve this? - prevent double counting
« Reply #2 on: 04 Nov 2016 12:54:12 pm »
Field 2 and 3 are from different query subjects - Field 2 is the beginning value, Field 3 is the month end value and the (a+b+c) are the different transactions for the user.

« Last Edit: 04 Nov 2016 12:56:11 pm by satiyabaazi »

Offline stan.parker

  • Full Member
  • ***
  • Join Date: Oct 2016
  • Posts: 29
  • Forum Citizenship: +0/-0
Re: How can I achieve this? - prevent double counting
« Reply #3 on: 04 Nov 2016 03:09:10 pm »
Can you explain which fields are in each query subject


Sent from my iPhone using Tapatalk

satiyabaazi

  • Guest
Re: How can I achieve this? - prevent double counting
« Reply #4 on: 07 Nov 2016 10:47:02 am »
Field 0 is the employee name
Field 1 is the addition/subtraction to Field 2 (beginning state) to obtain the values in Field 3 (ending state)
I want a summary row against each employee. Let's assume this example

Emp 1 has beginning state as 100$, the different additions to be considered are +5,-5,+10,-6 and ending state is 115$
So I want to find the value of the calculated variable that is 115-100+(5-5+10-6) = 19
I want this 19 number in my Field 4

Now I'm getting
115-100 + 5 = 20
115-100-5 = 10
115-100 + 10 = 25
115-100 - 6 = 9

and Field 4 becomes 20+10+25+9 = 63 = 19 + 45 (the extra 115-100 three times)

I hope I'm explaining it properly, I just can't seem to incorporate this in Query Studio. Thanks for you response!