what you are doing wrong?
Hm, I think you probably don't want to use subfield (this is for splitting up strings with given delimiter as 2. parameter), you could replace subfield with one of the match functions (e.g. wildmatch() ) instead.
I think a closing bracket is missing (but probably only in your copy in the post).
I would recommend doing the matching in the script, since it is static (you always want to do that, not depending on selection / input).
You could do this in the scipt using your above expression and an AS Fieldname statement.
(SALESPERSON and VAARREF are both fields, right?)
You could probably replace your nested ifs with a pick() function (like a switch statement).
Or, (I think this is what I would do), use a mapping table and applymap to map your different names.
Hope this helps,
Thanks a lot for your answers!
I'm afraid I'm not very good at SQL and do not know how to create a mapping table, but I will look for information on it.
Is there any good resource to find the formulas and syntax that Qlikview uses? I was not aware of the wildmatch-function, but I am sure you are right.
Also, the formula is like this, I forgot to change some things:
=if(subfield(SALESPERSON,'John'),'John Doe',if(subfield(SALESPERSON,'Alex'),'Alex Anderson','unknown')))
The first place to look for formulas and syntax is "F1" (or menu Help->Contents) when you are in QV.
This gets you into the QlikView Help file where you have a decent help.
Do that and search for "String functions"
You can also download the QV reference manual from the download area and read!
It goes into more detail.
Mapping is very straightforward - take a look at this:
[Man Map]: MAPPING LOAD [Manufacturer From], [Manufacturer To] FROM .... MAP [Manufacturer] USING [Man Map]; [Main Table]: LOAD [Manufacturer], ... FROM .... UNMAP [Manufacturer];
The [Man Map] table source is a 2 column source (e.g. an xls) that holds the values to look for ([Manufacturer From]) and what they should be replaced by ([Manufacturer To]). Its then turned on for a field named [Manufacturer] using the MAP statement, the table [Main Table] has this field name and so it gets applied here and then finally the mapping gets turned off (UNMAP). Thats it! A table created using MAPPING LOAD is automatically dropped at the end of the script so [Man Map] doesnt even need to be dropped in the code!
So grateful for your help, but there is something I don't get here...
I'm using a select * from [Table] to load data, where the table is part of an ODBC data connection. Where am I supposed to put this in the script when I am also using mapping? If I use LOAD * from [TABLE] it tells me that it can not open the file [TABLE] (makes sense because it isnt a file...)
Secondly, it tells me that it can not open the xls-file I created with the values. Is there something I forgot?
Sorry for these beginner questions, I find the qlikview way of loading data quite complex and I am very thankful for your help.
I dont use SQL connections but I believe that if you use a preceding load statement that should do it:
(SQL statement here)
so it just slots in as my earlier example.
If it doesnt allow you to open the xls containing your from/to mappings try creating the statement in the script with the 'Table Files...' wizard in case you have typos or something in your existing statement.