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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
BlandJ
Regular Visitor

can anyone help me work out why this returns "FALSE" for all rows? (CONTAINS function)

Hi all,

 

I am trying to identify all rows of data that contain certain values within a text string on 2 diferent fields:

 

Jan 2024 deal = AND ((CALCULATE(CONTAINS('ICISCreativeTrack Targeting2023','ICISCreativeTrack Targeting2023'[End_Date],"2023-12-31"))), (CALCULATE(CONTAINS('ICISCreativeTrack Targeting2023','ICISCreativeTrack Targeting2023'[Start_Date],"2022-"))))

 

have I used the wrong function here?

 

Is there a better way to find a text string to help me identify the right deals - both date fields are "text" format and I can't transform it.

 

many thanks Jo 

1 ACCEPTED SOLUTION

@BlandJ 

Technically yes you can but better to convert to text data type like

Jan 2024 deal =
IF (
ISEMPTY (
FILTER (
'ICISCreativeTrack Targeting2023',
AND (
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[End_Date], "2023-12-31" ),
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[Start_Date], "2022-" )
)
)
),
"No",
"Yes"
)

you may also use it as a count or visual level filter Like in

Jan 2024 deal =
COUNTROWS (
FILTER (
'ICISCreativeTrack Targeting2023',
AND (
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[End_Date], "2023-12-31" ),
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[Start_Date], "2022-" )
)
)
)

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

Hi @BlandJ 
Please try

Jan 2024 deal =
NOT ISEMPTY (
    FILTER (
        'ICISCreativeTrack Targeting2023',
        AND (
            CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[End_Date], "2023-12-31" ),
            CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[Start_Date], "2022-" )
        )
    )
)

That's works nicely - can I use this result in a visual? It seems ot only want to bring it through as a value not a row or column header.... do I need extra stuff in here to return a value of Y or N if it's true or false?   I'm slowly getting to grips with  DAX code but this one is eluding me!  Many thanks Jo 

@BlandJ 

Technically yes you can but better to convert to text data type like

Jan 2024 deal =
IF (
ISEMPTY (
FILTER (
'ICISCreativeTrack Targeting2023',
AND (
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[End_Date], "2023-12-31" ),
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[Start_Date], "2022-" )
)
)
),
"No",
"Yes"
)

you may also use it as a count or visual level filter Like in

Jan 2024 deal =
COUNTROWS (
FILTER (
'ICISCreativeTrack Targeting2023',
AND (
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[End_Date], "2023-12-31" ),
CONTAINSSTRING ( 'ICISCreativeTrack Targeting2023'[Start_Date], "2022-" )
)
)
)

BlandJ
Regular Visitor

thank you!

It's way better but I now get this error:  A single value for column 'End_Date' in table 'ICISCreativeTrack Targeting2023' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, coun

 

The data looks like this: 

BlandJ_0-1678295459861.png

 

 

FreemanZ
Super User
Super User

hi @BlandJ 

try like:

Jan 2024 deal = 
AND (
    CONTAINSSTRING(
      'ICISCreativeTrack Targeting2023'[End_Date],
      "2023-12-31"
    ), 
    CONTAINSSTRING(
       'ICISCreativeTrack Targeting2023'[Start_Date],
       "2022-"
   )
)
 
the solution would be easier if sample data could be provided.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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