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.
Conditional Formatting =
var SelectedGroupNm =SELECTEDVALUE(Budget[Budget])
var Result= IF([Cost]<= SelectedGroupNm || ISBLANK(SelectedGroupNm),0,1)
Return Result
In the above example, there is slicer called Budget and based on the one which is selected I am deriving a measure.
- saivina29205 years agoPost Prodigy
Sorry. i don't understand what you given.
my data available in slicer control. i am going to select only one at a time. Ex : 'EMP QUERY'[EMP_PLACE]
what ever i am selecting the slicer option control, that should pass as a variable in my expression as mentioned above.
can you pls. give us the below mentioned expression measure.
EMPSTATUS = CALCULATE (DISTINCTCOUNT ( 'EMP QUERY'[EMP_NUMBER] ),
( 'EMP QUERY'[EMP_REMARKS], "GOOD" ),( 'EMP QUERY'[EMP_COUNTRY], "INDIA" ),( 'EMP QUERY'[EMP_PLACE], $$$variables )
)- NandanHegde5 years agoSuper User
Hey, I have updated my answer with a simple DAX measure. Hope that would help you in utilizing the variables for selectedvalues within measures
- saivina29205 years agoPost Prodigy
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.??