In SharePoint calculated column, there is no COUNTIF function, and calculated fields can only operate on their own row, so you can't reference a value in another row, or columns contained in another list or library.
For formula conversion using flow, you can post your question in the Microsoft Power Automate Community. The experts there are willing to provide decent help for your issues.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.