Add up 2 multivalue fields in another multivalue field

I have for example 3 multivalue fields.In the first and second are numbers, the third one has to be the first + the second column.

Something like this:

Field1: Field2: Field3:


1 5 6

17 31 48

75 12 87

I tried to accomplish this with the following formula:

elements := @elements(drdfReceptions);

sumTotalRow := @For(i=0;i<elements;i:=i+1;

value1[i] := @If(drdfReceptions[i]=“”;0;@TextToNumber(drdfReceptions[i]));

value2[i] := @If(tdrdfHotels[i]=“”;0;@TextToNumber(drdfHotels[i]));

@Text(@Sum(value1[i]:value2[i])));

sumTotalRow

But that doesn’t work. Is it possible to get a certain value out of a multivalue field by using an array like [5] for the getting the 5th element in the multivalue field.

regards

Subject: add up 2 multivalue fields in another multivalue field

Try this:

Field1 + Field2

Subject: RE: add up 2 multivalue fields in another multivalue field

I tried that, the result of 15 + 15 is than 1515. He just sets the numbers after each other.

Subject: RE: add up 2 multivalue fields in another multivalue field

Sounds like you’re dealing with text fields. All of the fields in question have to be number fields. Or, I suppose, you could use @TextToNumber on both fields.

Subject: RE: add up 2 multivalue fields in another multivalue field

Even if I change the fields to number, he still sets one after the other. With @texttonumber my application gives an error, so that’s also not possible. That’s the reason for my post, the normal things don’t work.

This formula works:

value1 := @If(drdfReceptions=“”;0;@TextToNumber(drdfReceptions));

value2 := @If(drdfHotels=“”;0;@TextToNumber(drdfHotels));

value3 := @Text(@Sum(value1:value2));

value3;

But then he doesn’t total each line, but totals every line.

Field1: Field2: Field3:


1--------2--------36

3--------4

5--------6

7--------8

But I want this:

Field1: Field2: Field3:


1--------2--------3

3--------4--------7

5--------6--------11

7--------8--------15

Subject: RE: add up 2 multivalue fields in another multivalue field

The problem, I think, is not in the formula. It’s in the fields and data. If Field1 and Field2 are multivalue number fields, Field1 + Field2 will give you a list of sums of the individual members (try it yourself; create a new form with two editable multivalue number fields and a computed multivalue number field which adds the two together). If it isn’t working, then something’s up wrong the underlying data, and that is what you will have to fix. What kind of fields are Field1, Field2, and Field3? Are any of them text? Are any of them not set to take multiple values? What kind of data is in the documents? Actually look at the document properties and make sure that the data types match the field properties, because it’s possible that they don’t.

Subject: RE: add up 2 multivalue fields in another multivalue field

When you look at the properties, be sure to do it from the view, because looked at from inside the document, they can mirror the form even if they aren’t stored that way.

Subject: RE: add up 2 multivalue fields in another multivalue field

Indeed the problem was with the data type. I had a subform to fill in the multivalue fields in my mainform. In the subform the data type was number. In my mainform I received the data from the subform in hidden fields which were text fields.

And then I showed those fields in my mainform with visible fields which were number fields.

I made them all number and now it’s working.

Thanks for the tips!

Greetz