If you want the best performing way, you should use an OQL-statement. Something like
SELECT count(*) as NumOfMinorOccurences, NC_IMPACT
FROM NonConformance
GROUP BY NC_Impact
https://docs.mendix.com/refguide/oql#1-introduction
You can only retrieve and show data if you use an xpath datasource on a list view widget.
What you could do is create a new entity (i.e. NonConformanceCounter) with an integer attribute in which you will store the counted value and use a microflow datasource to create this entity.
In the microflow you should add the following actions:
Don't forget to set the proper access rights.
Based on the limited information provided i'd opt for a non persitent entity.