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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
cher90
Helper II
Helper II

How to check if two strings are available and if another string is not available between them?

Hello

 

How to check if two strings are available and if another string is not available between them?

 

data = "aaaa bbbb cccc dddd eeee ffff"

 

I want to generate "True" in the cell if "aaaa" and "eeee" exist and "cccc" does not exist between them? Is it possible to do that?

 

Thanks

Amine

1 ACCEPTED SOLUTION

Hi @cher90 ,

Please create a custom column.

if Text.Contains([data],"aaaa",Comparer.OrdinalIgnoreCase) 
and 
Text.Contains([data],"eeee",Comparer.OrdinalIgnoreCase) and
not Text.Contains([data],"cccc",Comparer.OrdinalIgnoreCase)=true then "TRUE" else "FALSE"

vpollymsft_0-1662620532404.png

Best Regards

Community Support Team _ Polly

 

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

7 REPLIES 7
cher90
Helper II
Helper II

Thaanks 😄

cher90
Helper II
Helper II

Actually I want to do this in power query but it doesn't work

 

cher90_0-1662619032522.png

 

cher90_1-1662619075803.png

 

Thanks for your help!

Hi @cher90 ,

Please create a custom column.

if Text.Contains([data],"aaaa",Comparer.OrdinalIgnoreCase) 
and 
Text.Contains([data],"eeee",Comparer.OrdinalIgnoreCase) and
not Text.Contains([data],"cccc",Comparer.OrdinalIgnoreCase)=true then "TRUE" else "FALSE"

vpollymsft_0-1662620532404.png

Best Regards

Community Support Team _ Polly

 

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

Thanks!

Hello

 

How to check if two strings are available and if another string is not available between them?

 

data

a
aaa bbb eee fff aaa hhh jjjj ccc
a
a
a
a
a
a

 

I want to replace the value with "True" in the cell if "aaa" and "eee" exist and "ccc" does not exist between them? Is it possible to do that?

 

 

 

Thanks

Amine

v-rongtiep-msft
Community Support
Community Support

Hi @cher90 ,

You can also create a column like @SergioSilvaPT 's.

column = IF( 
CONTAINSSTRING (('Table'[data]), "aaaa") && CONTAINSSTRING (('Table'[data]), "eeee") && NOT CONTAINSSTRING (('Table'[data]), "cccc"),
TRUE(),
FALSE())

vpollymsft_0-1662615887167.png

If I have misunderstood your meaning, pelase provide more details with your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

SergioSilvaPT
Resolver V
Resolver V

Hi  @cher90 ,

 

You can do that with IF and CONTAINSSTRING:

 

 

IF( 
CONTAINSSTRING (SELECTEDVALUE(Data), "aaaa") && CONTAINSSTRING (SELECTEDVALUE(Data), "bbbb") && NOT CONTAINSSTRING (SELECTEDVALUE(Data), "cccc");
TRUE();
FALSE())

 

 

Regards,
Sérgio Silva

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

Regards,
Sérgio Silva

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

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.