'PowerBI and SharePoint lists: How do I count the number of rows with the PID value equal to each row's UID (the 3rd column needs the formula)

I have a table below, and I need to calculate the last column as a custom measure/custom column. I'm grateful for any advice concerning the formulae. Please note this is a single table. The last column counts the number of rows which have as PID, the respective row's UID.

Please note, I am using SharePoint lists so addressing the ID column will be done via: 'SharePoint list name'[Id] which is the standard syntax when calling a SharePoint list column.

ID    PID   Count rows
1           2
2     1     1
3     1     0
4           0
5     2     0

Many thanks for considering my request.

I am using Power BI Desktop 2.83.



Solution 1:[1]

I found the answer:

Create a second identical SharePoint list and use the below.

Additional column =
    calculate (
        COUNTROWS('SharePoint list (replica)'),
        FILTER('SharePoint list (replica)','SharePoint list (replica)'[PID]='SharePoint list'[ID])
    )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 General Grievance