I'm attempting to implement countifs() like logic in a Power Query query, but not in a summary table referencing a source table. Rather I want to display all records and have it to be another column (in my actual use case this is necessary). Here's what I mean by that...
Input Data:
ID | Animal | Color
-- | ------ | -----
1 | Zebra | Red
2 | Zebra | Blue
3 | Zebra | Red
4 | Zebra | Red
Desired Output:
ID | Animal | Color | Count of others with same color
-- | ------ | ----- | -------------------------------
1 | Zebra | Red | 3
2 | Zebra | Blue | 1
3 | Zebra | Red | 3
4 | Zebra | Red | 3
In an excel inline formula, to calculate the column "Count of others with same color" I would use
=COUNTIFS([Animal],[@Animal],[Color],[@Color])
How could I do this in Power Query, using the M language?