Count variables - duplicates count as 1 and multiply with max. value

markush32574551

08-03-2018

Hello,

I have a little issue and don't know how to solve it. I tried following code with FormCalc to calculate the daily allowance, but didn't work properly.

I need to count the real amount of days, which means if the client needs two rows for one day it must only calculate it as one day.

The second thing (what I couldn't even start to program) is that it must multiplay the maximum quantity of technicians with each day.

Example:

3 technicians          18.03.2018          09:00 - 12:00

5 technicians          18.03.2018          13:00 - 16:00

Quantity of daily allowance: 5 technicians * 1 day = 1

I'm frustrated and hope anyone can help me out.

Thanks in advance, I appreciate what you are doin guys.

Best regards,

Markus

For the code and pictures of hierarchy see below.

ServiceReport.Hauptseite_kalk.Kalk.Kalk_2.Kalk2.dailyallowance.Quty::calculate - (FormCalc, client)

var val = Kalk1[*].Date_einf.rawValue

var spval = Kalk1[i].Date_einf.rawValue

var cou = Count(Kalk1[*].Date_einf)

var one = 0

var two = 0

     for i=0 upto cou do

          if (Count(val eq spval) eq 1) then

               one =+  Count(val eq spval)

// adds value 1 for days that are counted once

          elseif (Count(val eq spval) ne 1) then

               two =+ 1 / Count(val eq spval)

// explanation: if I count a one day two times e.g.:

// 18.03.2018

// 18.03.2018

// It would make one day counted as two, therefore I divide 1 / days

// 2 * (1 / 2) = 1 day -> Workaround

          endif

     endfor

this.rawValue = one + two

Unbenannt.PNG

View Entire Topic