You can use Aggregate List activity to take count using microflow.
There are various ways to aggregate (including counting) your data, depending on your desired need.
For instance, if you want the number of items using a microflow, you can retrieve from database, followed by the count aggregate function. Mendix has a built-in optimization that will, assuming you are not reusing the retrieved list again, only pull the aggregated value into memory.
If you want to display the count aggregate on the front-end, the Datagrid-widget (don’t think this is possible with Datagrid 2.0, but you can check), allows you to aggregate columns. The aggregated value will appear on the bottom of the column.
Hope it helps!~