Hi guys,
I will need to count the number of items i have in a row. I did a dt.rows.count.ToString but it counted all the cells in that row including empty cells. Please help.
Hi guys,
I will need to count the number of items i have in a row. I did a dt.rows.count.ToString but it counted all the cells in that row including empty cells. Please help.
Considering dt is your datatable variable, âdt.rows.countâ will not return all the cells in your rows, but would instead return all the rows in the datatable.
Use this instead:
dr.ItemArray.Length.toString to find the number of items in your row,
where dr is a specific row in your table dt.
~Sid
Hi Sid,
There is a error that says ItemArray is not a member of system.data.dataTable
Dear Kai,
It isnât obviously. Youâre using the datatable object instead of a data row object.
Try this:
dt.rows(0).ItemArray.Length.toString
Dt.select.where(function(row) row.item(0).tostring.isnullorempty).count
@Kai
If this helps, please mark the response as solution for other users
Hi Sid,
The results came back with only 1 where i have 4 items in that row.
Hi tdhaene,
Seems like there are errors in using isnullorempty. Hereâs the errors:
Overload resolution failed because no accessible âIsNullorEmptyâ is most specific for these arguments;
Extension method âpublic function IsNullOrEmpty() As Booleanâ defined in âSystem.Extensionsâ: Not most specific
Hello @Kai
try thisâŚ
dt.Select().Where(function( r) r(0).ToString.Count > 0).Select(function( r) r).CopyToDataTable.Rows.Count.ToString
above is for first column⌠change column index you requireâŚ
Can you copy paste your value of the assign statement,so i can verify?
Hello @Kai
Please check this workflow once to get an idea.
Sequence.xaml (9.0 KB)
Hi @vickydas
In your xaml, what if I want to get the rows with the empty cells instead of getting the rows with values?
Hello @RailCay
We would just have to change the conditions in our query and get the rows which have no value
Check this workflow out for better understanding
DT Rows.xaml (10.6 KB)