There are two ways of achieving this:
i. Use the modern control "Table". It shows the count of rows in the table by default.

ii. Your case where you are using the classic Datatable control. for this, in the Items property of your datatable, you must have written a Filter or Search PFx like the one shown below in my case.

to get the row count, i have added a label and in the Text property, I have used this PFx.
CountRows(the formula in the above Items property of the Datatable)

Note: CountRows(DataTable1.Selected.NSN) will not work as it deals only with the selected record(s) in the data table.
Hope this helps.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog James Yumnam