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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
moatazbelah
Regular Visitor

Group BY

Hello, I'm trying to write a code that extracts the number and creates this number in a new column. For example, in the picture below. In column A, I have 058aae, 058rre, etc.. so I want to write a formula that gives me the same result in column B. So the formula allows me to extract a specific value. Sometimes these values can be in anywhere in the sentence. For example, it can be in the beginning or in the middle, or in the end of the sentence. So for example, I want to write a formula that says " IF column A has 058, so then put 058 in column B, and if column A has 300, so then put 300 in column B, etc. 

Screenshot (394).png

1 ACCEPTED SOLUTION

Glad this is working, please mark any reply as a solution so the forum knows this has been resolved.
 
NewColumn_58 = IF ( SEARCH("58",'Table'[SampleText], , BLANK()) = BLANK(), "NotFound", "58")
NewColumn_300 = IF ( SEARCH("300",'Table'[SampleText], , BLANK()) = BLANK(), "NotFound", "300")
Multiple = IF ( SEARCH("58",'Table'[SampleText], , BLANK()) = BLANK(),
IF ( SEARCH("300",'Table'[SampleText], , BLANK()) = BLANK(), "NotFound", "300")
, "58")
 
** See in particular the example with 58 AND 300, whichever you serach for FIRST will show up first, and ignore any other found seraches... **
 
 

fhill_0-1650306963263.png

 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

5 REPLIES 5
fhill
Resident Rockstar
Resident Rockstar

When you say 'specfic value' do you only want Numberical Characters from a text field, so your 300trtg00g example would be 30000 instead of 300?  Or are you seraching for speicfic numbers in a mix of letter and numbers?




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




No, I'm searching for a specific value. so my 300trtg00g example would be just 300. So for example, I want to write a formula that says " IF column A has 058, so then put 058 in column B, and if column A has 300, so then put 300 in column B, etc. 

Check out this tool...

https://www.tutorialspoint.com/dax_functions/dax_search_function.htm

replace the serach text below with your coulmn...

 

Other = IF ( SEARCH("58","00aasdfsklafd", , BLANK()) = BLANK(), "NotFound", "58")   --  Returns NotFound change to BLANK() if you don't want a not found message
Other = IF ( SEARCH("58","00aasd58fsklafd", , BLANK()) = BLANK(), "NotFound", "58")  -- Returns 58 as text  (remove quotes to change to nuumber)
 
You'll have to nest further IFs if you want to search for more numbers in the same text returnign to the same column.
 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Thank you so much. it did work. Do you mind if you can nest further IFs to search for more numbers? because I'm having an issue with that. Thanks for your help 

Glad this is working, please mark any reply as a solution so the forum knows this has been resolved.
 
NewColumn_58 = IF ( SEARCH("58",'Table'[SampleText], , BLANK()) = BLANK(), "NotFound", "58")
NewColumn_300 = IF ( SEARCH("300",'Table'[SampleText], , BLANK()) = BLANK(), "NotFound", "300")
Multiple = IF ( SEARCH("58",'Table'[SampleText], , BLANK()) = BLANK(),
IF ( SEARCH("300",'Table'[SampleText], , BLANK()) = BLANK(), "NotFound", "300")
, "58")
 
** See in particular the example with 58 AND 300, whichever you serach for FIRST will show up first, and ignore any other found seraches... **
 
 

fhill_0-1650306963263.png

 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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