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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
GioVille
Regular Visitor

Extracting Maximum number in string

Hello, 

 

Is there a way to extract the maximum number in a string into a new column.

 

The number represents the number of attempts the test was conducted until I got a passing result. 

 

GioVille_0-1676949225212.png

Appreciate your help. Thank you in advance. 

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

NewStep=Table.AddColumn(PreviousStepName,"Custom",each List.Count(Text.Split([StatusColumnName],","))/2)

View solution in original post

2 REPLIES 2
jst_jdennis
Frequent Visitor

Yes, you can use Power Query to extract the maximum number in a string and create a new column for it. Here's how:

  1. Open Power Query by clicking on the "Data" tab in Excel and selecting "From Table/Range."
  2. Select the column that contains the string with the number of attempts.
  3. Click on the "Add Column" tab and select "Custom Column."
  4. In the formula bar, enter the following formula:

 

=List.Max(List.Transform(Text.Split([ColumnName]," "), each try Int64.From(_)))

 

 

Replace "ColumnName" with the name of the column that contains the string with the number of attempts. This formula splits the string into individual words, then converts each word to an integer (if possible) and returns the maximum value.

 

  1. Click "OK" and a new column will be added with the maximum number of attempts.

Note: If there are non-numeric values in the string, the formula will return an error. You may need to clean the data or modify the formula to handle these cases.

 

Credit: ChapGPT | https://chat.openai.com/chat

wdx223_Daniel
Community Champion
Community Champion

NewStep=Table.AddColumn(PreviousStepName,"Custom",each List.Count(Text.Split([StatusColumnName],","))/2)

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors