How to consider both Captital and Small Case

Hello Team,

We are currently using this condition in data table

(CDbl(((dt_System.AsEnumerable.Where(Function(x)x(“Group No”).ToString.Contains(“400”)).Sum(Function(x)CDbl(x(“Absolute Dependency”).ToString.Trim))).ToString.Replace(“.”,“”).Replace(“,”,“.”)))*(-3)).ToString

How can we modify this and add a condition here to consider column as

Absolute Dependency or Absolute dependency

It could be either of them

Thanks Everyone

1 Like


Tha Absolute dependency is the column name right you have to give the proper column name, first check in the datatable which it is in small or capital case.

If you have given any wrong case in column names in linq it will not work properly. We can’t modify like that by giving cases with Or.

Hope it helps!!

Hii @mkankatala

Actually the column names are not static

At time’s its present as Absolute Dependency

And in other’s it’s present as Absolute dependency

So wanted to remove the case sensitivity here


Try the below two linqs:

CDbl(((dt_System.AsEnumerable.Where(Function(x) x("Group No").ToString.Contains("400") And (x("Absolute Dependency").ToString.Trim <> "" Or x("Absolute dependency").ToString.Trim <> "")).Sum(Function(x) CDbl(If(x("Absolute Dependency").ToString.Trim <> "", x("Absolute Dependency").ToString.Trim, x("Absolute dependency").ToString.Trim).Replace(".", "").Replace(",", "")))) * (-3)).ToString

Second one:

CDbl(((dt_System.AsEnumerable.Where(Function(x) x("Group No").ToString.Contains("400") AndAlso (x("Absolute Dependency").ToString.Trim <> "" OrElse x("Absolute dependency").ToString.Trim <> "")).Sum(Function(x) CDbl(x("Absolute Dependency").ToString.Trim.Replace(".", "").Replace(",", "")))) * (-3)).ToString

Let me know which is working

Hope it helps!!


Considering you would want to Find the Column Name match between the two names mentioned we could try it with the below Expression which retrieves only the matching column names from the Datatable :

columNameMatch = {"Absolute dependency","Absolute Dependency"}.Intersect(DT.Columns.Cast(Of DataColumn).Select(Function(x)x.ColumnName).ToArray).FirstOrDefault

Here columnNameMatch is a String variable which should contain the matching column name within the Datatable columns and DT is the Input datatable variable.

You can then check if columNameMatch is not empty and then use the variable in place of the hardcoded column name.

Let us know if this does not work.


A small correction columnNameMatch with given formula might not be a string but an array or zenumerable …if you use first or (0) it might be giving you the string


1 Like

Thanks @mkankatala , @supermanPunch and @Anil_G for your prompt responses


Thank you @NISHITHA

Happy Automation!!

@Anil_G , @NISHITHA ,

Edited the Expression in the above post.

1 Like

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