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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Babinsky
Helper I
Helper I

How to find a single character from a field and then create a new field

Hi all, I have a question for you.  

 

Do you know what the IF statement would be to find a single character from a field to create a new field?

 

For example:  When field A contains 'T' then create field B.  The field A is a text field for example T142536, S18273 etc...

 

I am trying to create a new field if the search criteria = T within field A

 

- Babinsky

1 ACCEPTED SOLUTION

Hi @Babinsky,

 

Great to hear the problem got resolved! Could you accept the corresponding reply as solution to help others who may have similar issue easily find the answer and close this thread?Smiley Happy

 

Regards

View solution in original post

12 REPLIES 12
paulag
Advocate I
Advocate I

how about using the left function

=if(left(Field A,1)="T",Field A,"")

temp.png

Thanks for the suggestions but they didn't work.  I found the solution if anyone is curious.

 

SELECT * FROM file

WHERE field1 LIKE 'T%';
 
That created the new field I wanted that contained the value T.
Sean
Community Champion
Community Champion

Okay then! Smiley Happy

Did that work for you?  I did it in Excel Power Query just to test it.  I can do a screen grab in PBI desktop if you want

Yes it did work, Have a great day everyone!

 

- Babinsky

Hi @Babinsky,

 

Great to hear the problem got resolved! Could you accept the corresponding reply as solution to help others who may have similar issue easily find the answer and close this thread?Smiley Happy

 

Regards

Done

Sean
Community Champion
Community Champion

I'm assuming you want a new COLUMN

 

Give this a Try

 

New Column =
IF (
    ISERROR ( FIND ( "T", Table[Column], 1 ) ),
    "No there's no T",
    "Yes there is a T"
)

Hope this helps.

Good Luck!Smiley Happy

I saw your reply thanks!

 

New Column = IF ( ISERROR ( FIND ( "T", Table[Column], 1 ) ), "No there's no T", "Yes there is a T" )

 

Is the following syntax standard?  "No there's no T", "Yes there is a T"

 

It doesn't look like normal coding procedures.  I trying to create a new field based on the contents another.

Sean
Community Champion
Community Champion

The question was: "Do you know what the IF statement would be to find a single character from a field to create a new field?"

 

My Normal Coding Procedures do not include reading minds. But you can output whatever you want

 

Find Function.png

 

Thanks for offering a suggestion.  this is getting me closer sorry for not being clear.

 

What I'm looking to create is for Example - Field1 contains ex: T000 and S000 and I want to create a new field with T000 only.

 

Not create a Yes or No value.

Sean
Community Champion
Community Champion

Do you want a New Column or a New Table?

 

This will give you the new COLUMN like in my picture above

 

New Column =
IF (
    ISERROR ( FIND ( "T", Table[Column], 1 ) ),
    BLANK(),
    Table[Column]
)

 Find Function2.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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