extract the first digit out of 4 digits or the first 2 out of 5

Jaapaap

New Member
Joined
Sep 28, 2023
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hello all,

I would like to add a new column to my PowerBI dashboard.
I have an origin column with numbers. some of the numbers exist out of 4 digits and some out of 5

I would like to extract out of the numbers with 4 digits only the first digits. If the number exists out of 5 digits, i would like to extract the first 2 digits.

example

existing column --> new column
12345 --> 12
4353 --> 4
5674 --> 5
11096 --> 11

can anybody help me with a formula code that works, Thanks in advance
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi and welcome

Try

varios 28sep2023 busqueda parcial.xlsm
AB
11234512
243534
356745
41109611
Hoja3
Cell Formulas
RangeFormula
B1:B4B1=LEFT(A1,IF(LEN(A1)=4,1,2))
 
Upvote 0
Hi DanteAmor,

I have more or less this formula but i cannot find the mistake

GH = LEFT('QI_'[Batch #],IF(LEN('QI_'[Batch #]=4,1,2)))
 
Upvote 0
I think you have an extra parenthesis on the right side.
But you also have problems with the table and column name. (I don't know what your table or column is called).

Just create the formula, Excel automatically gives you the names of the table and the column.

Try:

Dante Amor
ABC
1Batch #
21234512
343534
456745
51109611
Hoja3
Cell Formulas
RangeFormula
C2:C5C2=LEFT(Q1_[Batch '#],IF(LEN(Q1_[Batch '#])=4,1,2))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,357
Messages
6,124,483
Members
449,165
Latest member
ChipDude83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top