Creating IF/Else Formula - Extract Root Domain

Discuss the spreadsheet application
Post Reply
cristopher
Posts: 3
Joined: Tue Jun 25, 2019 5:45 am

Creating IF/Else Formula - Extract Root Domain

Post by cristopher »

I am trying to take a list of URL links and extract the root domain from each for further comparison.

The issue I am running into is that my files consist of 4 different URLs: http://domain.com/something/; https://domain.com/something/; http://www.domain.com/something/; and https://www.domain.com/something/

I have 2 separate formulas that work, but only 1 does for the "www" URLs and the other for the "non-www" files. See below:

www
=IF(ISERROR(FIND("//www.";A2));MID(A2;FIND(":";A2;4)+3;FIND(":";A2;4)-3);MID(A2;FIND(":";A2;4)+7;FIND("/";A2;9)-FIND(":";A2;4)-7))

non-www
=IF(ISERROR(FIND("//";A2));MID(A2;FIND(":";A2;4)+3;FIND(":";A4;4)-3);MID(A2;FIND(":";A2;4)+3;FIND("/";A2;9)-FIND(":";A2;4)-3))

How can I create 1 single formula that will check all 4 types of URLs and extract the domains?

I have attached my test document to view each formula working separately. Thank you very much if anyone can help.
Attachments
formula.ods
(10.41 KiB) Downloaded 95 times
Cris
OpenOffice 4.1.6
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Creating IF/Else Formula - Extract Root Domain

Post by robleyd »

Are your domains limited to .com; or do they include generic TLDs; might they have a country code like .co.uk or .com.au?
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
cristopher
Posts: 3
Joined: Tue Jun 25, 2019 5:45 am

Re: Creating IF/Else Formula - Extract Root Domain

Post by cristopher »

robleyd wrote:Are your domains limited to .com; or do they include generic TLDs; might they have a country code like .co.uk or .com.au?
They are all types of domains, including subdomains. I appreciate your time in helping.
Cris
OpenOffice 4.1.6
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Creating IF/Else Formula - Extract Root Domain

Post by Zizi64 »

Use helper cells for the simplier formulas. When you store the partial results in a some separated cell cells, then you not needed to repeat the parts of the formula in a huge single formula.
Last edited by Zizi64 on Tue Jun 25, 2019 7:45 am, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
cristopher
Posts: 3
Joined: Tue Jun 25, 2019 5:45 am

Re: Creating IF/Else Formula - Extract Root Domain

Post by cristopher »

Zizi64 wrote:Use helper cells for the simplier formulas. When you store the partial results in a separated cell, then you not needed to repeat the parts of the formula in a huge single formula.
Thanks, so I can do this by using helper cells? I have never used those before so I am somewhat unclear about them.
Cris
OpenOffice 4.1.6
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Creating IF/Else Formula - Extract Root Domain

Post by Zizi64 »

so I can do this by using helper cells? I have never used those before so I am somewhat unclear about them.
formula_with_helper_cells.ods
(14.99 KiB) Downloaded 116 times
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Creating IF/Else Formula - Extract Root Domain

Post by robleyd »

Your use of the term root domain is potentially misleading here; taken literally that might suggest that your expected result for the samples in your first post would all be domain.com or even .com

Can you describe precisely what you are trying to to; for example you might want to strip anything up to and including the first pair of slashes; if the next four characters are www. then strip them; finally strip anything from and including the next slash.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Post Reply