Forum Discussion
saurabhtd
Resolver II
3 years agoNeed help in DAX Logic
I want to do a calculation of DISTINCTCOUNT(TableName[customercode]) of customers from all three countries. But when I select country from countryname filter these conditions should be satisfied. wh...
tamerj1
Community Champion
3 years agoHi saurabhtd
Please try
=
VAR SourceN =
SWITCH (
SELECTEDVALUE ( TableName[CountryName] ),
"A", "X",
"B", "X",
"C", "Z"
)
RETURN
CALCULATE (
DISTINCTCOUNT ( TableName[customercode] ),
TableName[SourceName] = SourceN
)- saurabhtd3 years ago
Resolver II
Thanks for replying. Now when I select particular country in filter I am getting required answer. But how to get deafult condition which is to calculate distinctcount(customer code) when all the countries 'A','B','C' are selected in the filter. I am strucked at this point now.
- tamerj13 years ago
Community Champion
saurabhtd
I believe this should be fully dynamic therefore no need for default value.= VAR SourceN = SELECTCOLUMNS ( VALUES ( TableName[CountryName] ), "@Country", SWITCH ( TableName[CountryName], "A", "X", "B", "X", "C", "Z" ) ) RETURN CALCULATE ( DISTINCTCOUNT ( TableName[customercode] ), TableName[SourceName] IN SourceN )