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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

CONTAINS gives same result on every line

Hi, it's the first time that I post. I am quite new at Power Bi.

I have been trying to understant how to use the CONTAINS function. I do the same thing as the video does but I keep getting the same result for every line. I m trying to get true if the column A =1 and if the column B = 2, if not --> false

So I wrote: 

Contain = CONTAINS('Table','Table'[PRIX A],1,'Table'[PRIX B],2)
I only have one column for which this statement is true but it still says true for everything(picture below). I tried several alternatives but no matter what I do, I have the same value for each line (either all false either all true)
 
Can anyone help me?
Loladba_0-1645180594308.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

If you use calculate column, the Contains() function is for all data in each column.

For example:

As long as there is one row in the data of the two columns [PRIX A] and [PRIX B] that satisfies the conditions of [PRIX A]=1&&[PRIX B]=2, the whole calculated column will all display True, if not satisfied, all will display False.

 

If Measure is used and it is a table visual table, each row is equivalent to a data table, so at this time there is only this row of data in the data table.

For example:

[PRIX A]=1,[PRIX B]=2, it is equivalent to an independent table, this table also has only this row of data, and it is True if it meets the conditions

[PRIX A]=2,[PRIX B]=2, this row is also equivalent to an independent table, but if it does not meet the conditions, it is False.

vyangliumsft_0-1645509502977.png

https://towardsdatascience.com/power-bi-calculated-measures-vs-calculated-columns-9be012e9bff1

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @Anonymous ,

If you use calculate column, the Contains() function is for all data in each column.

For example:

As long as there is one row in the data of the two columns [PRIX A] and [PRIX B] that satisfies the conditions of [PRIX A]=1&&[PRIX B]=2, the whole calculated column will all display True, if not satisfied, all will display False.

 

If Measure is used and it is a table visual table, each row is equivalent to a data table, so at this time there is only this row of data in the data table.

For example:

[PRIX A]=1,[PRIX B]=2, it is equivalent to an independent table, this table also has only this row of data, and it is True if it meets the conditions

[PRIX A]=2,[PRIX B]=2, this row is also equivalent to an independent table, but if it does not meet the conditions, it is False.

vyangliumsft_0-1645509502977.png

https://towardsdatascience.com/power-bi-calculated-measures-vs-calculated-columns-9be012e9bff1

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you,

 

But then does that mean that we can't use CONTAINS in a calculated column?

Tahreem24
Super User
Super User

@Anonymous, Follow above measure suggestion using CONTAINS else try with IF ELSE using calculated column:

 

Capture.JPG

 

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

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Tahreem24
Super User
Super User

@Anonymous Create a measure to get the result. Refer the below screen shot:

Capture.JPG

 

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

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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