Как преобразовать текст в число в гугл таблице

от admin

How to Convert Text to Number in Google Sheets [3 Easy Ways]

When working on a spreadsheet, you often encounter an issue where a formula isn’t working properly. Most of the time, this is due to the data not being in a proper format in the cells. This can cause a lot of issues in your work. First, your data won’t be consistently formatted; secondly, when performing calculations, some data may be ignored by the formulas as it won’t be detected as a number.

This article will answer the question, “Can Google Sheets Convert Text to Number?” as well as some easy methods to check whether Sheets recognizes the data in cells as text strings or numbers in the first place.

Table of Contents

How to Tell When Number Is Text

Before we can employ the techniques to convert text to a number, we first need to check whether Google Sheets considers the data in the cell a number or a text string. There are multiple ways to do this. Let’s take a look at some of them:

Check the Alignment

This method is the fastest and easiest way to check the data’s format inside the cells. By default in Google Sheets, text content is aligned to the left, while numbers are aligned towards the right. Using this method, you can tell by just a glance whether the data in a cell is a number or a text value.

However, note that this method only works if you’re using the default alignment of the data in the cells. If you change the alignment of the cells, then you won’t be able to tell just by looking at the cells. If this is the case, you will have to use a more advanced method to check if the data is text or a number.

Use the SUM Function

The SUM function can find the total of numerical values in two or more cells or a cell range. Here is the syntax for the function:

The val parameters are the number or the range you wish to add together. We will use the SUM function to add the values to check whether the data in a cell is a number or a text value.

When this function is used to add text values in cells, the output is 0. However, when adding numbers, the function works as expected and returns the sum of the values in the cells.

Use ISTEXT and ISNUMBER

Although the SUM function is useful, it doesn’t work when a cell range contains text and a number. When this happens, the function will ignore the value in that cell and sum up all the other values. This makes the SUM function unreliable when cells have different types of values.

This is where the ISTEXT and ISNUMBER functions come in. They provide a fool-proof method for checking the type of data in a cell. Here is the syntax for the ISTEXT and ISNUMBER functions:

The val parameter is the cell containing the data value. The formula will return a TRUE or FALSE value depending on the function used and the data inside the cell.

To use this function, we can enter the formula beside the cell and copy the formula to the other cells using the fill handle. Alternatively, you can use the ARRAYFORMULA to use the function in multiple cells.

How to Convert Text to Number in Google Sheets

Now that we know if the data in the cell is a number or text, we can look at methods to convert the text to number Google Sheets.

Google Sheets Convert to Number by Multiplication

This is one of the easiest ways to convert text to number in Google Sheets. All you have to do is multiply the data in a cell by 1. This will force the output to be shown in a number format.

There are multiple ways you can do this. Here are a few formulas you can use:

In this example, we are using the first method. In the cell beside the one containing the values, enter the cell name, an asterisk sign, and 1. Press Enter to execute the formula. You can use the suggested autofill feature to fill the formula in all spreadsheet cells or by using the fill handle.

Google Sheets String to Number Using the Format Menu

Using the format menu in Google Sheets allows you to change the format of the cells. Here are the steps you need to follow to extract a number from a string with the format menu:

  1. Select the cells you wish to format.
  2. Click on Format in the top bar.
  3. In the drop-down menu, click on Number.
  4. Click on Number in the sub-menu.

Once the process is completed, the values in the selected cells will be formatted as a number. They should also automatically align to the right.

In the same menu, you can also create a custom number format. While selecting the cells:

  1. Click on Format in the top bar and then Number.
  2. Click on Custom number format. Here you can type in custom instructions for the formatting of the numbers.
  3. Click Apply. That will save the format. Follow the steps mentioned above to apply the custom formatting.

Google Sheets Text to Number With the Value Formula

You can use another simple function to convert text to number in Google Sheets. The VALUE formula. Here is how it works:

The text parameter is the cell address containing the data you wish to convert to a number.

To use this formula, enter it in the desired cell and write the cell address as the parameter. Press Enter to execute the formula.

Frequently Asked Questions

How Do I Change Text to Number in Google Sheets?

You can convert a text string into a number in your spreadsheet in several ways. One of the simplest ways is to use the format menu, accessed by clicking on Format in the top bar and then clicking on Number. There, choose Number again, and the data in the selected cells will change to number formatting.

How Do I Change a Text to a Number?

To change the data format in a cell to number, you can multiply the cell’s contents by 1. You can also use the VALUE formula in Sheets to change the data in a cell from a text string to a number value.

Wrapping Up the Google Sheets Convert Text to Number Guide

Any of these methods work in under a few seconds. But, the quickest way for Google Sheets to convert text to number is to go through the format menu as it checks and changes in a single move.

Related Content: Convert to Phone Number Format in Google Sheets. You can change plenty of other things in the format menu too, like capitalizations. So, it’s a great idea to familiarize yourself with the format menu.

Как преобразовать текст в числа в Google Таблицах

Вы можете подумать, в каком сценарии мне нужно будет преобразовать текст в числа в документе Google или в таблицах Google. Подумайте об этом так: если вам дадут электронную таблицу с числами, будет легко вывести некоторые формулы, необходимые для правильного расчета того, что вы пытаетесь проанализировать.

С другой стороны, «текстовый» формат этих чисел может очень затруднить, а иногда даже сделать невозможным получение этих же формул.

Когда вы имеете дело с такими измерениями, как валюта, в которой необходимо число для анализа, формулы чрезвычайно полезны и могут сэкономить много времени.

В этой статье мы рассмотрим, как преобразовать «текстовый» формат в «числовой» в таблицах Gooogle, чтобы упростить выполнение ограничений формулы.

Преобразование текста в числа с помощью функции VALUE

Есть несколько формул, которые можно использовать для преобразования текста в числа в Google Таблицах.

Когда вы хотите преобразовать текст в число, первый вариант, который у вас есть, — это использовать функцию VALUE (ЗНАЧЕНИЕ) как таковую:

Замените точки запятыми, чтобы преобразовать текст в числа

К сожалению, это не всегда сработает, когда вы получаете данные из файла, в котором вам нужно преобразовать «текстовый» формат в «числовой» формат.

Возможно, вам предоставлены файлы, в которых запятые заменены на «.» или «точки» и читаются в «текстовом» формате.

Иногда это происходит, когда вы получаете сообщения из стран, в которых используется точка вместо запятой.

В этом случае вы захотите использовать другую формулу:

Это работает аналогично функции «REGEXTRACT ()» в том, что она находит и заменяет «текстовый» формат числа на «числовой» формат числа.

Это работает путем замены символа «.» с «,». Это поможет преобразовать число «143,244» в «143,244», которое совпадает с «143244», которое можно использовать в формуле для расчета.

Фактически вы можете проверить, работает ли это, используя число, полученное из «текстового» формата этого числа, используя его в вычислениях.

Преобразование данных с денежным текстом в число

Когда вы импортируете данные из другого документа в Google Таблицы, вы можете столкнуться с символом «$» или другим денежным форматом перед числом в виде «текста». Вы можете сделать это, используя формулу «В чистое число» как таковую:

Извлечение чисел из текста

Иногда вы можете импортировать фрагмент текста из другого набора данных. Этот текст может быть целым предложением, внутри которого написаны числовые значения.

Например, ячейка A1 содержит следующий текст:

В прошлом месяце я заплатил 200 долларов за обслуживание блога. Ожидается, что в этом месяце я заплачу всего 150 долларов за меньшее количество услуг.

Читать:
Как подключиться к базе данных c

Позвольте мне показать вам две формулы, чтобы это сделать:

Формула Метод 1

Чтобы извлечь числа из этого текста, мы будем использовать функции «Split» и «Concatenate» одновременно.

Как видите, часть «200 долларов» от вывески не избавилась. Если это важно, мы можем легко вернуться и использовать формулу «Чистое число», упомянутую ранее.

Формула Метод 2

Мы также можем использовать функцию «Разделить» вместе с функцией «Regexreplace».

Как видите, оба метода делают одно и то же в отношении извлечения числа из текста.

Итак, вот несколько методов, которые вы можете использовать для преобразования текста в числа в Google Таблицах .

3 Ways to Convert Text to Numbers in Google Sheets

This post is going to show you how you can find numbers entered as text values and convert them to numbers in Google Sheets.

You might run into issues where the numbers in your dataset are formatted as text values.

Unfortunately, identifying this can be tricky.

When numbers are formatted as text without you knowing about it, that’s can be a frustrating experience.

Luckily, you have this article to help prevent any frustration.

In this post, you will learn how to check the formatting of your cell contents, and also how to convert numbers formatted as text to numeric values.

Get your copy of the example workbook to follow along.

How to Tell When a Number is a Text Value

Before you use any of the techniques to convert text to numbers, you first need to know that the numbers are in fact not numbers.

The following methods will help to check the formatting of the numbers in your dataset.

Check for Text with Alignment

This method is the quickest and easiest means by which you can tell the cell formatting of your data.

By default, texts contents are aligned to the left while numeric values are aligned to the right.

This allows you to tell at a glance whether or not the cells have the correct formatting.

All you have to do is look at your cells and check for the alignment of their contents.

However, it’s important to mention that you can only rely on this method insofar as you don’t change the alignment setting in your spreadsheet.

If you’ve changed the alignment format, you can refer to any of the following methods.

Check for Text with the SUM Function

The SUM function will return the aggregate of numeric values or the values in a cell range.

But when the SUM function is used on a range of text values it returns 0. This way you know the numbers are not in the right format.

Check for Text with the Status Bar

For this method, select the cells and check the type of operation carried out in the status bar.

If it shows a Count as it does in the image above, then you know the numbers are formatted as text.

When the contents are formatted as numbers, the status bar will show a Sum for the numbers in the range.

Check for Text with the ISTEXT or ISNUMBER Function

The previous two methods discussed suffer from a crucial flaw.

When the selected cell range contains both text and numeric values, they will ignore the text contents and return the sum of the numeric values in the range.

For instance, if only one cell out of 200 cells has a number formatted as text then you will not spot it as the sum will ignore the text values and treat them as zero.

The calculations you carry out will be wrong, and that can seriously affect the outcome of your analysis!

You can avoid all of this messy situation by using either one of the ISTEXT or ISNUMBER functions. They will give you a fool-proof test regarding the type of formatting present in each cell.

ISTEXT checks whether a value is a text string.

ISNUMBER checks whether a value is numeric.

Enter the above function syntax into a new cell. Then use the fill handle to copy down the formula to other cells.

Alternatively, you can use place the function in an ARRAYFORMULA like above.

This will return TRUE for any cell which contains text values.

You can also follow the same process to use the above ISNUMBER syntax.

This will return FALSE if the number is a text value.

The only drawback with this method is that you have to create a new column of redundant data. Nevertheless, you will be certain of which cells have numeric content and which have text values.

Now that you know how to identify the type of formatting in a cell, you might want to change these text characters to numeric values.

Convert Text to Numbers by Multiplication

There is a very easy way to convert text values to numbers, you simply have to multiply by 1. This will force the results into a number.

In a new cell, copy and paste any of the above formula syntaxes.

The values will become numeric. You will be able to confirm the conversion by the obvious right alignment of the cell contents.

Convert Text to Numbers with Format Menu

The Format menu contains options that you can use to change cell format. This means you can change the format from text to number.

Select the cells with the contents you want to change their format.

  1. Go to the Format menu
  2. Select the Number option.
  3. Select Number.

When you complete the process, the contents of your cells should be right-aligned indicating they’re now numeric values.

Instead of using the Number format, you can create a custom format.

While your cells are selected, go to the Format menu and click on Numbers. Then select Custom number format.

In the dialogue box that opens, copy the formatting instruction into the search bar and click Apply.

Convert Text to Numbers by VALUE Function

Another function you can use to change the text to numbers is the VALUE function.

The VALUE function takes a text string and converts it to a numeric value. It’s the perfect function for the purpose that you want to achieve.

Copy and paste any of these formula syntaxes into a new cell. The result will be the conversion of the text string into numeric values.

Convert Text to Numbers with an APPS SCRIPT

The apps script allows you to create custom functions and menu commands that meet your needs.

You can access the apps scripts editor by going to the Extensions menu and selecting the Apps Script option.

Check out the guide to Apps Scripts in Google Sheets for more information on this powerful tool.

In your code editor window, copy and paste the above code syntax. Click on Save, then Run. Grant the necessary permissions and refresh your spreadsheet window.

After you refresh your spreadsheet, the syntax will create a new menu item labeled Number.

In this custom menu item, you will find the submenu Change to Number Format. This command will convert the text to numeric values.

The script essentially uses a Custom number format using the setNumberFormat(«####.00») method to convert the text to numbers.

Conclusions

The processes described above show the importance of having your numeric cell contents in the correct number format.

Now you can easily identify and apply the appropriate fixes to change any text values to numbers.

Using the MULTIPLICATION and VALUE functions to change the format provides you with a dynamic approach. You can embed them into larger functions to carry out more operations at once.

But adding new columns can increase the file size of the spreadsheet, thereby reducing the speed at which it responds.

The Format menu and apps script option doesn’t require you to create redundant data by creating extra columns. You can use these to directly change the source data.

Do you know of any other method for changing text to numeric format? Let me know in the comments below!

Преобразование текста в число в Google Таблицах

Я читаю значения валюты с веб-сайта и хочу произвести расчеты с этими числами. Они бывают в таком формате: 7821,24 доллара.

Теперь по какой-то причине у меня не работают ни VALUE (), ни TO_PURE_NUMBER (не могу выполнить синтаксический анализ до числового значения, сообщая мне, что это текстовое значение). Я предполагаю, что запятая и знак $ путают формулу, могу ли я что-нибудь сделать, чтобы ее правильно отформатировать? Знак доллара всегда появляется в значениях, но запятая появляется только между тысячами значений.

Я только начал использовать для этого Таблицы, поэтому понятия не имею. Был бы очень признателен, если бы кто-нибудь мог мне помочь. Спасибо за ваше время!

1 ответ

Выпуск :

Это проблема локали. Значение, поступающее из IMPORTXML , отформатировано как в локали United States , поэтому ваша электронная таблица (в которой используется другой формат) не может преобразовать его.

Решение №1. Смена локали:

Если языковой стандарт электронной таблицы изменен на United States или другие с тем же форматом (путем выбора File > Spreadsheet settings и установки упомянутого языкового стандарта), полученное значение будет числом, и вы можете работать с ним без использования каких-либо другая формула.

Решение №2. Формула:

Если изменение языкового стандарта невозможно, одним из возможных способов преобразования значения в допустимое число в вашем языковом стандарте является следующая формула:

Похожие статьи