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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.