Forum Discussion
How do we call variables in DAX measure
- 5 years ago
Hi saivina2920 ,
Please try this.
EMPSTATUS = VAR variables = SELECTEDVALUE('EMP QUERY'[EMP_PLACE]) RETURN CALCULATE( DISTINCTCOUNT ( 'EMP QUERY'[EMP_NUMBER] ), FILTER( ALL('EMP QUERY'), 'EMP QUERY'[EMP_REMARKS] in { "GOOD", "EXCELLENT"} && 'EMP QUERY'[EMP_COUNTRY] = "INDIA" && 'EMP QUERY'[EMP_PLACE] = variables ) )Best regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey, I have updated my answer with a simple DAX measure. Hope that would help you in utilizing the variables for selectedvalues within measures
Ok. thanks.
I tried the below DAX Measure, but, getting unexpected error.
MEASURE =
var VAR1 =IF(ISBLANK(SELECTEDVALUE('EMP QUERY'[EMP_PLACE])),CALCULATE(DISTINCT('EMP QUERY'[EMP_NO],FILTER('EMP QUERY','EMP QUERY'[EMP_REMARKS]="GOOD" && 'EMP QUERY'[EMP_COUNTRY]="INDIA" && 'EMP QUERY'[EMP_PLACE]= SELECTEDVALUE('EMP QUERY'[EMP_PLACE])))))
return CALCULATE(DISTINCT('EMP QUERY'[EMP_NO]),FILTER('EMP QUERY','EMP QUERY'[EMP_NO]=VAR1))
where condition is below (Filter) :
'EMP QUERY'[EMP_REMARKS]="GOOD" AND
'EMP QUERY'[EMP_COUNTRY]="INDIA"
passing variable :
SELECTEDVALUE('EMP QUERY'[EMP_PLACE])
DISTICT VALUE :
'EMP QUERY'[EMP_NO]
can you pls. check what is the problem in my DAX Measure.??
- NandanHegde5 years agoSuper User
Hey,
Based on your measure :
Your variable is returning rows (multiple Emp_Nos)
So QUERY'[EMP_NO]=VAR1 wont work. you can think of using IN dax or containsrow.
And it would be better if you also provide the error msg in case if any and the base data and your exepcted result. That might help in better understanding your scenario 🙂- saivina29205 years agoPost Prodigy
pls. find the sample image for your reference.
- saivina29205 years agoPost Prodigy
pls. let us know if need any more details.