How do I extract values from a table in Extraction Results and sum them?

Hi All,

Need urgent help here.

I have a variable ExtractionResults which contains the extracted results from a PDF document. In it I have a table called “Items”. The table items has a field unit price. Post extraction is done and before presenting to the validation station. I want to calculate the total(addition) of unit price column.
Example if the table contains 5 rows with values 8.25 then total I should get is 41.25 as total then I will store it to a new field. First problem here is getting all the values of that column from extractionresults and summing them.

Please help!

HI @Dhruvi_Arumugam ,

You need to export the extraction results to a dataset first by using “Export Extraction Results” activity. dataset will have multiple data tables. Example dataset(0) will acquire the header data and dataset(1) will acquire the table data. then you can use the below syntax to get one row value from your table

dataset.Tables(0).Rows(0)(1).ToString

you can put a loop and increase your row number to sum the unit price column

Thanks,
Palavi

Thankyou for the reply @lchirathapudi

If suppose I got the total amount example 2564, now if I want to assign this value to a new field which is defined in Taxanomy already field name Line Total. How can i do that?

Find the column number for your Line Total column in dataset.tables(0) then , apply for each current row in that data table take an assign activity save like in the below screenshot

in the screenshot , currentRow(4) is my column number where I want to insert the Unit price

Hope this information helps, let me know if you still have doubts

Thanks,
Pallavi.

No, It is like .

Once I am able to get the total which I am able to get using extractionresults logic you told and summing it up.

After that the total which I got I want to assign it the field of extraction results like I am doing below But getting error - Index was out of bound of array.

Assign LHS
io_ExtractionResults.ResultsDocument.Fields(FieldsDict(“Level Total”)).Values(0).Value

Assign RHS
TableValueExtraction.Tables(“Items”).AsEnumerable().Sum(Function(x) If(Not String.IsNullOrWhiteSpace(x(“Line Amount”).ToString()), Convert.ToDecimal(x(“Line Amount”).ToString()), 0)).ToString

ao i am assigning the total obtained to the field of extraction result.

Have you tried like I have showed in the screenshot? You need to use for each loop and add your assign activity inside for each loop

Calculate this and add to a variable first and see if you are having any problem with RHS expression

TableValueExtraction.Tables("Items").AsEnumerable().Sum(Function(x) If(Not String.IsNullOrWhiteSpace(x("Line Amount").ToString()), Convert.ToDecimal(x("Line Amount").ToString()), 0)).ToString

Hi @Dhruvi_Arumugam

Is your query resolved?

If yes, then please mark the post you found as solution so that it helps other community members to find the solution if anyone having same query.

Regards

as mentioned in your other topic. we would prepare a datapoint and then assign it to
io_ExtractionResults.ResultsDocument.Fields(FieldsDict(“Level Total”)).Values