Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hello,
I'm trying my journey with dax and i step into issue which i can't find a solution...
I have table with CityLocation and Value and want count number of CityLocation where value is > 0.
For below result it should be 2.
I can get eaisly count of CityLocation where Value is >0 however how i can count unique City ?
CityLocation | Value |
Torotno1 | 0 |
Toronto1 | 3 |
NewYork2 | 0 |
Toronto3 | -1 |
Denver1 | 0 |
Denver2 | 1 |
Solved! Go to Solution.
@joshua3m
I can assume from your code that Value is a measure. In this case please try
COUNT =
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
FILTER ( VALUES ( 'Table'[CITYLOCATION] ), [VALUE] > 0 ),
"City", LEFT ( 'Table'[CITYLOCATION], LEN ( 'Table'[CITYLOCATION] ) - 1 )
)
)
)
Hi @joshua3m
Please try
Count =
CALCULATE ( DISTINCTCOUNT ( 'Table'[CityLocation] ), 'Table'[Value] > 0 )
Hi Tamerj ,
Would this not calculate distinct only for CityLocation where i want actually look into City and not City Location combine ?
I was trying to do as below:
COUNT:
COUNTROWS(
FILTER(
ADDCOLUMNS(
VALUES(LEFT([CITYLOCATION],LEN[CITYLOCATION]-1),
"STOCK" , ([VALUE])
),
[STOCK] >0
)
)
@tamerj1 wrote:Hi @joshua3m
Please try
Count =
CALCULATE ( DISTINCTCOUNT ( 'Table'[CityLocation] ), 'Table'[Value] > 0 )
@joshua3m
I can assume from your code that Value is a measure. In this case please try
COUNT =
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
FILTER ( VALUES ( 'Table'[CITYLOCATION] ), [VALUE] > 0 ),
"City", LEFT ( 'Table'[CITYLOCATION], LEN ( 'Table'[CITYLOCATION] ) - 1 )
)
)
)
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
17 | |
10 | |
9 | |
8 | |
7 |
User | Count |
---|---|
20 | |
11 | |
8 | |
6 | |
6 |