This process will read the data, calculate the total “GROSS PREMIUM” for each unique combination of “FINAL” and “Approval Date”, and write the summarized data to a new sheet in the Excel file.
The error “Option Strict On disallows late binding” occurs because Option Strict enforces early binding, meaning that all variable types must be known at compile time. In your case, row("FINAL") and row("APPROVAL DATE") are likely being treated as Object types, which Option Strict does not allow to be used directly without explicit casting
Updated UiPath Workflow:
Assign Activities:
Add separate Assign activities to cast the values before combining them.
Build DataTable and configure the three output columns
FINAL, APPROVAL DATE, GROSS PREMIUM
out: dtResult
Assign Activity:
dtResult =
(From d in dtDataTableVar.AsEnumerable
Group d by k1=d("FINAL").toString.Trim into grp=Group
Let fs = grp.Sum(Function (g) CDbl(g("GROSS PREMIUM").toString.Trim))
Let ra = new Object(){k1, g.First()("APPROVAL DATE"), fs}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
feel free to adapt conversions and extending the grouping to also the Approval Date
The error “Option Strict On disallows late binding” occurs because Option Strict requires that the types be known at compile time. In this case, kvp.key is being treated as an Object, and Option Strict does not allow implicit conversions. To resolve this, you need to explicitly cast kvp.key to a String.
as 2 different approaches were shared with you, so decide on which one you want to implement first. Then be strict on this line and have an understanding on what is aimed.
he error message indicates that key is not a member of System.Collections.Generic.Dictionary(Of String, Double). This suggests that your dictionary’s keys and values are not being accessed correctly in your code.
To resolve this, you need to properly access the key-value pairs in your dictionary. Here’s a detailed explanation of how to do this correctly:
Correct Approach for Accessing Dictionary Elements
Ensure Proper Typing:
Your dictionary dict should be of type Dictionary(Of String, Double).
In your For Each loop, the variable kvp should be of type KeyValuePair(Of String, Double).
Accessing Key and Value:
Use kvp.Key to access the key.
Use kvp.Value to access the value.
String Operations:
Ensure that any operations on kvp.Key or kvp.Value are compatible with their