Sam332
Sam332

Reputation: 67

How to count how many times a value appears in a list based on another column in Power BI?

I have this sample table

City Store
City1 STORE1
City1 STORE2
City1 STORE3
City2 STORE4
City3 STORE5
City3 STORE6
City3 STORE7
City4 STORE8

I want to show a card that will tell me how many stores are present in the table in a city. For example, if I have a slicer and I pick Store1, the card should read 1 of 3 because it's 1 store of a 3 within the same city.

What's the best way to approach this?

Upvotes: 0

Views: 1115

Answers (1)

smpa01
smpa01

Reputation: 4346

Can you try the following measure

_count:=
COUNTROWS ( 'Table' ) & " " & "of" & " "
    & CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[city] ) )

SOlution

Upvotes: 1

Related Questions