-1

What I'm trying to do is trim an FQDN down to just the name of the asset.

For example, let's say I have a machine called "Desktop1.mycompany.com" and I just want to have the value "Desktop1" in another field.

I've done a trim command Trim(Left([ColumnwithFQDN],(InsStr(1,[ColumnwithFQDN],".")-1))) and it works. It removes everything but the machine name.

However, I notice this list has some computer names without the FQDN and they're just showing up as "Desktop2". Obviously, this causes a #Func! error.

My question is: is there any way to either skip anything that's not in the FQDN or have it just return the original value if the function fails?

I think I could do an IIf(IsNull) command, but I'm not sure what I would be setting as the value to return.

HansUp
  • 95,961
  • 11
  • 77
  • 135
howradisit
  • 43
  • 3
  • 12
  • I guess I just associated "trim" with an existing Excel command that I incorporated from an existing spreadsheet. It had a trim command that did what I wanted, but maybe the command was used out of context. – howradisit Sep 24 '18 at 16:12

1 Answers1

0

The Trim function removes leading and trailing spaces from a string, and neither a hostname nor an FQDN can contain such, so that function isn't needed here. Of course, you can apply it in the end, if you wish. The interesting part is the Left function in this case. I suggest to use the following expression:

Left([ColumnwithFQDN], Len([ColumnwithFQDN]) - InStrRev(StrReverse([ColumnwithFQDN]), "."))

Same as with the solution of @HansUp, you have to be sure that [ColumnwithFQDN] isn't Null.

Wolfgang Kais
  • 4,010
  • 2
  • 10
  • 17