Getting the street number from a street address

Erike
New Member

Hello.

I need to get an address for the correct geographical location.

For this I need the street number, the town, the zip code and the state.

The problem I have is with the street address. Customers provide us with an address that includes the apartment and the floor. For example, they tell us calle Alcalรก 222 4 izquierda (izquierda is left in Spanish)

That means that his address is in Calle de Alcalรก 222. It is a fourth floor, apartment on the left.

And usually this is written in many different ways:

calle Alcalรก 222 4 izquierda
Alcalรก 222 4Izq
Calle Alcalรก 222 4ยบ izquierda
Alcalรก 222 4-Izq

For purposes of geographical location what is needed is calle Alcalรก 222.
I have managed to solve it but with the help of 3 virtual columns.

The first column determines the number: 222 and it does it in the following way

TOP(EXTRACTNUMBERS([shippingAddressStreet]),1)

This generates a list type field with a single value that is 222.

I have not been able to find an expression that converts this list field into a text field

I do it by creating another virtual column of type text whose content is equal to the previous column.

Once I have that second column of text what I do is

CONCATENATE(LEFT([shippingAddressStreet], FIND([Ex Address 2], [shippingAddressStreet])-1), [Ex Address 2])

Where [Ex Address 2] is the virtual column 2

I already have calle Alcalรก 222.

What I am looking for is an expression that allows me to move from a LIST field to a Text field in order to avoid using so many virtual columns.

This solves almost all directions, but there is a special case that I am not able to solve.

Occasionally there are street numbers that are duplicated. For example, there is a building at calle Alcalรก 222 and another one at calle Alcalรก 222 Duplicated.

From the point of view of geographical location it is not so important. These buildings are next to each other.

The problem comes with the nomenclature of the address. They are usually written like this:

calle Alcalรก 222B 4-Izq
calle Alcalรก 222-B 4-Izq
calle Alcalรก 222 B 4-Izq
calle Alcalรก 222 Dup 4-Izq
calle Alcalรก 222Dup 4-Izq

The problem comes when there is a letter attached to the number, for example 222B or 222Dup. In those cases the algorithm does not work properly.

When the customer writes calle Alcalรก 222B 4-Izq

TOP(EXTRACTNUMBERS([shippingAddressStreet]),1) returns the value 2220000000

Any suggestions on how I can solve this?

Solved Solved
0 9 638
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Use INDEX(EXTRACTNUMBERS([shippingAddressStreet]),1) instead.

View solution in original post

9 REPLIES 9

Steve
Platinum 4
Platinum 4

Use INDEX(EXTRACTNUMBERS([shippingAddressStreet]),1) instead.

Thanks Steve. That worked perfect!!

Do you have a suggestion for the second issue?

@Erike
I believe AppSheet interprets 222B as 222 Billion as itโ€™s a scientific notation.

Your comment makes a lot of sense.

Provided the street number is always 3 digit, you can try with this:

NUMBER(LEFT(CONCATENATE(TOP(EXTRACTNUMBERS([shippingAddressStreet]),1)),3)

Thanks @LeventK LeventK

Unfortunately is not always 3 digits. Normally it a number from 1 to 3 digits. No street is long enough for requiring 4 digits yes

Hooray!

Unfortunately, no. AppSheetโ€™s text processing capabilities are limited, and really not up to the complexity of this particular challenge. Were I in your place, I might consider trying to do the processing in the spreadsheet using regular expressions (which are themselves a huge complexity).

Will explore that possibility.
I imagine the implications are:
Need to define a new real column in the spreadshhet
Add any expression required in the that spreadsheet column
Define the same real column in appSheet.

Thanks in advance

Correct!

Unfortunately, the result of the spreadsheet formula will only be available after a sync. Keep that in mind if you try to use the result in other expressions within the app.

Top Labels in this Space