Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hello, I encountered an error with DAX measure.
The error is:
A function SELECTEDVALUE has been used in a scalar predicate filter expression. This is not allowed
The measure is:
CALCULATE([product_count],all(DIM_PRODUCT), DIM_PRODUCT[PRODUCT_GROUP] = SELECTEDVALUE(DIM_PRODUCT[PRODUCT_GROUP]) &&
DIM_PRODUCT[PRODUCT_SUPGROUP] = SELECTEDVALUE(DIM_PRODUCT[PRODUCT_SUPGROUP]))
how to fix this error?
Solved! Go to Solution.
Hi @MKPA ,
Thanks for the reply from @Uzi2019 , please allow me to provide another insight:
Problems arise with direct use in Filter expressions because the Filter context therein requires Boolean expressions or Table Filter expressions, rather than using scalar values directly.
You can use variables to store SELECTEDVALUE(DIM_PRODUCT[PRODUCT_GROUP]) and SELECTEDVALUE(DIM_PRODUCT[PRODUCT_SUPGROUP]), and then replace them with your original Measure syntax, for example:
Measure =
VAR _a= SELECTEDVALUE(DIM_PRODUCT[PRODUCT_GROUP])
VAR _b= SELECTEDVALUE(DIM_PRODUCT[PRODUCT_SUPGROUP])
RETURN
CALCULATE(
[product_count],
ALL(DIM_PRODUCT),
DIM_PRODUCT[PRODUCT_GROUP] = _a,
DIM_PRODUCT[PRODUCT_SUPGROUP] = _b
)
If that does not solve your problem, please provide the pbix file to help you further, and remember not to log into your account when uploading the pbix file in Power BI Desktop.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi @MKPA ,
Thanks for the reply from @Uzi2019 , please allow me to provide another insight:
Problems arise with direct use in Filter expressions because the Filter context therein requires Boolean expressions or Table Filter expressions, rather than using scalar values directly.
You can use variables to store SELECTEDVALUE(DIM_PRODUCT[PRODUCT_GROUP]) and SELECTEDVALUE(DIM_PRODUCT[PRODUCT_SUPGROUP]), and then replace them with your original Measure syntax, for example:
Measure =
VAR _a= SELECTEDVALUE(DIM_PRODUCT[PRODUCT_GROUP])
VAR _b= SELECTEDVALUE(DIM_PRODUCT[PRODUCT_SUPGROUP])
RETURN
CALCULATE(
[product_count],
ALL(DIM_PRODUCT),
DIM_PRODUCT[PRODUCT_GROUP] = _a,
DIM_PRODUCT[PRODUCT_SUPGROUP] = _b
)
If that does not solve your problem, please provide the pbix file to help you further, and remember not to log into your account when uploading the pbix file in Power BI Desktop.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi @MKPA
Try to use VALUES() instead of selectedvalues.
I hope It may resolved your issue!