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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PC2022
Helper III
Helper III

CONTAINS formula or something else?

I need to calculate sum score based on criteria that all 5 review phases evaluations are present for the project ID. For example, for the project below, the score shouldn't get calculated, as only 2 phases have been completed. 

PC2022_1-1745345170761.png

EvalJobComp = CALCULATE(SUMX(crb87_consultantevaluation,

([EvalDesignComp30] * 0.7) + ([EvalConstrComp] * 0.3)),
CONTAINS(crb87_consultantevaluation, crb87_consultantevaluation[Review Phase], "30% Design") ||
CONTAINS(crb87_consultantevaluation, crb87_consultantevaluation[Review Phase], "60% Design") ||
CONTAINS(crb87_consultantevaluation, crb87_consultantevaluation[Review Phase], "100% Design") ||
CONTAINS(crb87_consultantevaluation, crb87_consultantevaluation[Review Phase], "Mid-Construction") ||
CONTAINS(crb87_consultantevaluation, crb87_consultantevaluation[Review Phase], "Construction/Final"))
 
I get an error: a function "contains" has been used in a true/false expression that is used as a table filter expression.
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Use CONTAINSSTRING instead.

View solution in original post

9 REPLIES 9
PC2022
Helper III
Helper III

Used Containsstring. Doesn't give error anymore but not returning any results although i know there are projects where all phases evals exist.

EvalJobComp = CALCULATE(SUMX(crb87_consultantevaluation,
([EvalDesignComp30] * 0.7) + ([EvalConstrComp] * 0.3)),
CONTAINSSTRING(crb87_consultantevaluation[Review Phase], "30% Design") &&
CONTAINSSTRING(crb87_consultantevaluation[Review Phase], "60% Design") &&
CONTAINSSTRING( crb87_consultantevaluation[Review Phase], "100% Design") &&
CONTAINSSTRING( crb87_consultantevaluation[Review Phase], "Mid-Construction") &&
CONTAINSSTRING( crb87_consultantevaluation[Review Phase], "Construction/Final"))

what happened to the ORs ?  Your filter needs to say  II,  not &&

all 5 evaluations need to be there, so i need to use "and" &&

Logical operations are the other way round from casual speech.  Your condition will ONLY be true if ALL the percentage strings are included in [Review Phase] TOGETHER.

so what is the solution then 🙂 ?

put the ORs back in.

 

EvalJobComp = CALCULATE(SUMX(crb87_consultantevaluation,
([EvalDesignComp30] * 0.7) + ([EvalConstrComp] * 0.3)),
CONTAINSSTRING(crb87_consultantevaluation[Review Phase]"30% Design") ||
CONTAINSSTRING(crb87_consultantevaluation[Review Phase]"60% Design") ||
CONTAINSSTRINGcrb87_consultantevaluation[Review Phase]"100% Design") ||
CONTAINSSTRINGcrb87_consultantevaluation[Review Phase]"Mid-Construction") ||
CONTAINSSTRINGcrb87_consultantevaluation[Review Phase]"Construction/Final"))

maybe i am not explaining it correctly - it can't be OR. 30, 60, 100, mid and final eval must be there for EvalJobComp score

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

lbendlin
Super User
Super User

Use CONTAINSSTRING instead.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.