Jakobee
Jakobee

Reputation: 3

Counting rows with the same name in PowerBI

I'm new to PowerBi and I need some help with DAX for counting the rows with the same name. I have a table like that:

Name Cost
Albert 2137
Daniel 2234
Albert 2137
Mark 2234

And I want to know how many times did the name appeared so it would look like that: | Name | Cost | NameCount | | -------- | -------- |------------| | Albert | 2137 | 2 | | Daniel | 2234 | 1 | | Albert | 2137 | 2 | | Mark | 2234 | 1 |

I need it as all of the rows with the same name have the same cost and I would like to make another visual that would show the cumulative sum of all the distinct Cots ( so I would add the Albert value once not twice ) and I wanted to just make then another column that would be Cost/NameCount and the visual to show the sum of that.

I tried that but for it gives me 3 so just gives a number of distinct Names:

CountName = VAR CurName = MAX(Parents[ParentName]) VAR Result = CALCULATE(COUNTROWS(Parents),FILTER(Parents,Parents[ParentName] = CurName)) Return Result

Upvotes: 0

Views: 624

Answers (1)

Sia
Sia

Reputation: 536

NameCount = CALCULATE(COUNT('Table'[Name]),ALLEXCEPT('Table','Table'[Name]))

enter image description here

Upvotes: 1

Related Questions