Mulitplication of bracket value in excel

Please find attached screenshot
image

when there is single value in cell normal multiplication formula should be implemented which is in this case - =A1*B1

If there are two values (2,3) in this case then it should take formula =(22)+(33)
and the number of value is not fixed in cell C2 its (2,3) ,C3 its (1,2,3) it may increase or decrease
Is this possibile in UiPath ?

Hi,

How about the following?

mc1 = System.Text.RegularExpressions.Regex.Matches(CurrentRow.ByIndex(0).ToString,"\d+")
mc2 = System.Text.RegularExpressions.Regex.Matches(CurrentRow.ByIndex(1).ToString,"\d+")

result = mc1.Cast(Of System.Text.RegularExpressions.Match).Zip(mc2.Cast(Of System.Text.RegularExpressions.Match),Function(m1,m2) CInt(m1.Value)*Cint(m2.Value)).Sum()

Sample20221220-6L.zip (8.8 KB)

Regards,

can you explain me the result variable what is it doing not aware of .Cast and .Zip

Hi,

Cast method returns IEnumerable. We can use LINQ to the collection.

Zip method iterate 2 collections in order.

For example. in (1,2,3) (1,2,3) case,

mc1 has 3 items from regex.Matches, like “1”, “2”,“3”
mc2 also has 3 items like “1”, “2”, “3”

Zip method iterate 2 collections, like m1 =“1” and m2 =“1” then calculate 1*1 by Int(m1.Value)*Cint(m2.Value), next m1=“2” and m2=“2” then calculate 2*2
Finally, sum the above results by Sum method.

Hope this helps you.

Regards,

test.zip (1.7 KB)
Let me know, if have any doubts…Thanks

If the scenario is (1,2) (4,5) and i want that it should take formula as =2*((14)+(25)) so basically its multiplying by 2 so what changes will be required in result variable?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.