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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.