Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
MKPA
Regular Visitor

SELECTEDVALUE Error

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? 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.

vhuijieymsft_0-1714115482297.png

 

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!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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.

vhuijieymsft_0-1714115482297.png

 

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!

Uzi2019
Super User
Super User

Hi @MKPA 
Try to use VALUES() instead of selectedvalues.

 

I hope It may resolved your issue!

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors