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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Tobias2019
Regular Visitor

If - else function with two Text.Contains functions combined with "and"

Dear all,

 

I try to achieve a combination of Text.Contain statements, but I fail with that. I don't know where to look at, maybe you do have an idea.

 

I have got following structure in my table:

 

Interface nameError statement
Interface appleThere is a mismatch
Interface bananaThere is a mismatch

 

The relevant part of the statement looks like this:

if (Text.Contains(Error Statement], "There is a mismatch") and Text.Contains([Interface name] = "apple")) then "Result 1"
else if (Text.Contains(Error Statement], "There is a mismatch") and Text.Contains([Interface name] = "banana")) then "Result 2"

 

 

 

The error message which I receive is:

An error occurred in the ‘xxx’ query. Expression.Error: The field 'Interface name' of the record wasn't found.

 

Thank you in advance,

Tobias

1 ACCEPTED SOLUTION
VasTg
Memorable Member
Memorable Member

@Tobias2019 

 

I was able to create a new column for the specified condition with final else condition. Make sure to use the correct column names.

 

VasTg_0-1572449707164.png

 

Let us know if this helps.

Connect on LinkedIn

View solution in original post

5 REPLIES 5
Tobias2019
Regular Visitor

Hello together,

 

I managed to solve the issue.

The statement of @VasTg is correct!

In my special case, I had a formatting issue in the column, which I used for the second statement (Interface name). Although I used the Text.Contains function and only searched to a small part of the text, the query brought up errors.

Now I used another column containing similar information and here it works.

 

Anyone else having the same problem: Use the query how @VasTg buildt it. If you fail, first try to use another column to check, if the query is the problem or your data format.

 

Topic solved!

 

Thanks & regards,

Tobias

gooranga1
Power Participant
Power Participant

hi @Tobias2019 

 

looks like you have missed a [ at the start of the field name.

 

bracket.png

@gooranga1 

Thanks for you reply. This was only a copy&paste issue. I copied my original statement and replaced the values with some samples.

VasTg
Memorable Member
Memorable Member

@Tobias2019 

 

I was able to create a new column for the specified condition with final else condition. Make sure to use the correct column names.

 

VasTg_0-1572449707164.png

 

Let us know if this helps.

Connect on LinkedIn

@VasTg: Thanks your reply. In your screenshot I noticed something, which I was doing wrong: I used a "=" instead of a "," in the second statement. But still I receive this error message:

 

An error occurred in the ‘xxx’ query. Expression.Error: The field 'Interface name' of the record wasn't found.

 

One more information which I missed to provide: My if-else contains several loops. Only two of them are extended with an "and" clause.

Do you think Power BI might have an issue in this regard?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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