Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

IF Statement Calculation Total

Avatar

Level 1

I'm trying to create a LiveCycle form that we can use to record our truckers miles and corresponding pay data. To save some explaining, here's a screenshot with my setup:

ScreenShot1.jpg

I am having trouble with the formula to automatically calculate the Total Miles @ $0.35 from the lines above. Note: the first 4 data lines above are not a table and the data will vary from entry to entry. In this example, I would like the Total Miles @ $0.35 to show 4,000 (because that is what the data above indicates).

Here's the formula that I've come up with from researching the internet:

TotalNumMiles35.rawValue = IF(LineOne.Rate.rawValue eq "0.35") then + LineOne.Units.rawValue + IF(LineTwo.Rate.rawValue eq "0.35") then + LineTwo.Units.rawValue   .....and so forth. Adobe does not agree with my formula!!!

I am trying to write this form using the FormCalc method. Basically, what I'm after is: IF the value under Line1 Rate = 0.35, then include the value under Line1 Units to the total in Total Miles @ $0.35, and IF the value under Line2 Rate = 0.35, then also include the value under Line2 Units in the total... If someone could help with the initial formula I should be able to figure out the rest for the different options (Total Miles @ $0.45, Total Labour...etc).

Thanks in advance for any help. My knowledge with LiveCycle/Adobe is almost zero...

Thanks,

Mark

2 Replies

Avatar

Level 10

First of all I can see that you are using a decimalField for your rates so using "0.35" is not gonna work...

and you can't write down and if (statement) then with a + right after

try this out

if (LineOne.Rate.rawValue eq 0.35) then

     Total Miles @0.35 = LineOne.Units.rawValue

endif

if (LineTwo.Rate.rawValue eq 0.35) then

     Total Miles @0.35 += LineOne.Units.rawValue

endif

if.... and goes on for all of your statement

Avatar

Level 1

Hi Magus069,

Thank you for responding. I was wondering if you could help me a little more? With a little tweaking I was able to get the total number of miles to show up for one of the lines if the rate was 0.35; however, I keep getting an error message when I type the second script in. Here's the error I get:

ScreenShot2.jpg

Here's what I have typed in for script:

if (LineOne.Rate.rawValue eq 0.35) then TotalNumMiles35 = LineOne.Units.rawValue endif

if (LineTwo.Rate.rawValue eq 0.35) then TotalNumMiles35 += LineOne.Units.rawValue endif

I must be missing something obvious. Any ideas? Just to reiterate what I'm trying to accompolish, there will be several (10 or so) rows. There will only be four rate options available (0.35, 0.45, 12.00, and 15.00) and the user will select which row they will be applied on (ie, they will vary from row to row). I want the form to calculate the total number of units for each rate.

If you have any other suggestions I would greatly appreciate it. As I mentioned earlier, I know very little about this program and have tried everything I can think of.

Thank you,

Mark