Parse Data

Pestomania

Active Member
Joined
May 30, 2018
Messages
332
Office Version
  1. 365
Platform
  1. Windows
I have a dataset that I cannot modify as it is a kick out from a database. In some cases the value has a 0 at the beginning and sometimes it does not. This causes parsing problems.

I have put together the "current data return" and "the correct data" in the below data. How can I write a formula that will parse the data to ensure the 0# in the center is the floor and everything before is the location and everything after is the post?



ASSETS by BUSUNIT.xlsx
ABCDEFGHI
1DataLocationFloorPostDataLocationFloorPost
203224R01BB2603224R01BB2603224R01BB2603224R01BB26
303224R01N1303224R01N1303224R01N1303224R01N13
402278M02A1002278M02A1002278M02A1002278M02A10
502278M02B0802278M02B0802278M02B0802278M02B08
603224R0103224R01 03224R0103224R01 
703224R01BB3203224R01BB3203224R01BB3203224R01BB32
803224R01G2603224R01G2603224R01G2603224R01G26
95508701B085508701B085508701B085508701B08
105506101C025506101C025506101C025506101C02
115506101D095506101D095506101D095506101D09
12CURRENT DataCorrect Data
Sheet1
Cell Formulas
RangeFormula
B2:B11,G2:G8B2=LEFT(A2,6)
C2:C11,H2:H8C2=MID(A2,7,2)
D2:D11,I2:I8D2=MID(A2,9,5)
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Maybe, in B2
Excel Formula:
=LET(sStr,A2,SeqA,SEQUENCE(LEN(sStr)),zPos,(IF(CODE(MID(sStr,SeqA,1))=48,SeqA,0)),kPos,IF(MAX(zPos)>7,LARGE(zPos,2),LARGE(zPos,1)),HSTACK(LEFT(sStr,kPos-1),MID(sStr,kPos,2),TRIM(MID(sStr&"  ",kPos+2,99))))
Then copy down

It works in the combinations you shown, not sure it will work in ALL the possible combinations. I assumed (based on some of your words) that floor ranges from 00 to 09
 
Upvote 0
Solution
It worked in all except for 85 cases because their formatting was completely different.

I appreciate the help!
 
Upvote 0
If these 85 have all the same style maybe we can fix the situation
 
Upvote 0
If these 85 have all the same style maybe we can fix the situation
These are the ones that are broken.

Majority of the issues fall under these categories:

- 6 digits only = building # only
- OUTSIDEF18:
building: Outside
Column: F18
- 03187SB1U05
Building: 03187S
Floor: B1
Column: U05

03217L
02278MM1B01
OUTSIDEF15
OUTSIDEF14
OUTSIDEF14
OUTSIDEF14
OUTSIDEF14
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
02278MM1A01
02278MM1A01
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
OUTSIDEF13
02278MM1B02
OUTSIDEF13
02278MM1B02
OUTSIDEF13
03191MB1D02
03191MB1B02
03191MB1E03
03191MB1D02
02297F
03212T
02319K
03225Q
01198D
04118F
02293N
OUTSIDEJ22
03187SB1X03
03238LM1H14
03238LM1H13
03238LM1H12
03187SB1U05
03187SB1X06
03225N
03187SB1M05
02278M
02314J
03222O
01283FRF
02294N
03199T
02297FB1L31
02297FB1E23
02297FB1N31
OUTSIDEA17
OUTSIDEA17
OUTSIDEA17
OUTSIDEA17
OUTSIDEA17
OUTSIDEF16
OUTSIDEA17
OUTSIDEF17
OUTSIDEA17
OUTSIDEA17
OUTSIDEF18
OUTSIDEF18
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
02278MRF
OUTSIDEA17
OUTSIDEA17
 
Upvote 0
Try
Excel Formula:
=LET(aStr,A2,sStr,IF(LEFT(aStr,7)="OUTSIDE",SUBSTITUTE(aStr,"OUTSIDE","OUTSIDE00"),aStr),SeqA,SEQUENCE(LEN(sStr)),zPos,(IF(CODE(MID(sStr,SeqA,1))=48,SeqA,0)),kPos,IF(MAX(zPos)>7,LARGE(zPos,2),LARGE(zPos,1)),IF(LEN(aStr)>6,IF(kPos<6,{"**","**","**"},HSTACK(LEFT(sStr,kPos-1),MID(sStr,kPos,2),TRIM(MID(sStr&"  ",kPos+2,99)))),aStr))
This should fix (I guess) the condition when string is 6 or less digits long, and the OUTSIDE position.
Conditions like 03187SB1U05 create an output in the form ** \ ** \ ** so they can be identified and manually fixed; indeed I don't see a rule that can be used to deal with that condition (the location may be 5 or 6 digits, the Column may be 3 or 4: quite hard to guess where Floor starts from)
 
Upvote 0
Try
Excel Formula:
=LET(aStr,A2,sStr,IF(LEFT(aStr,7)="OUTSIDE",SUBSTITUTE(aStr,"OUTSIDE","OUTSIDE00"),aStr),SeqA,SEQUENCE(LEN(sStr)),zPos,(IF(CODE(MID(sStr,SeqA,1))=48,SeqA,0)),kPos,IF(MAX(zPos)>7,LARGE(zPos,2),LARGE(zPos,1)),IF(LEN(aStr)>6,IF(kPos<6,{"**","**","**"},HSTACK(LEFT(sStr,kPos-1),MID(sStr,kPos,2),TRIM(MID(sStr&"  ",kPos+2,99)))),aStr))
This should fix (I guess) the condition when string is 6 or less digits long, and the OUTSIDE position.
Conditions like 03187SB1U05 create an output in the form ** \ ** \ ** so they can be identified and manually fixed; indeed I don't see a rule that can be used to deal with that condition (the location may be 5 or 6 digits, the Column may be 3 or 4: quite hard to guess where Floor starts from)
Absolutely, I am going to recommend they do a cleanup where if something doesn't exist, put a 00 to at least make everything the same length.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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