Forum Discussion
joshua3m
3 years agoFrequent Visitor
Count Table Distinct
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. ...
joshua3m
3 years agoFrequent Visitor
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 )
tamerj1
3 years agoCommunity Champion
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 )
)
)
)