1

This is going to be a fairly easy question for you I think.

I have a lookup aimed at a Data Extension, but I want to set a default value for all lookups that does not find a value in the DE.

Here is the complete script I have right now for reference - SnipSave.

And here is the Data extension - Google Documents

It contains more variables but lets just focus on one now. So here is a rough "mockup" what I want to achieve

IF @studyloc = *values from first coloumn in DE*  
SET @studyloccorr = Lookup("SFdataCorr_StudyWhere", @prefix_lang, "StudyWhere", @studyloc)
ELSE
SET @studyloccorr = *default value*

The default value should be different depending on the country as well (column headers) just like all the other values (like NewYork for example).

So if the @prefix_lang = EN then the default value should be "default", but if @prefix_lang = ES then the default value should be "vamos" (stupid example)... and so on with every column.

So essentially we would insert an additional row for the default values in theory, but I'm not sure then how would we say if the lookup was unsuccessful then look at this added row.

Can you help me with this or steer me to the right direction?

Regards, Balint

1

You may want to use LookUpRows() instead of LookUp(). You can test the number of rows returned with LookUpRows() using rowcount, and default if nothing is returned.

LookUpRow returns a rowset. Row is used to access a row from the RowSet (1 indexed). Field is then used to access a field from the row.

@RS = LookUpRows("DEName", "FieldName1", "ValueToQuery")
@Row = Row(@RS, 1)
@FieldValue = Field (@Row, "FieldName2")
| improve this answer | |
  • Hey mobo, I'm not quite sure I understand how the LookUpRows function works. So it returns the entire row, right? How would we choose which value is going to be used from the data set at the end? Can you write an example? (sorry if my dilemma seems simple, I just started working with AMPscript. – Balint Jul 7 '14 at 16:42
  • I think I cracked it finally. I created another row for the default values and had that looked up after the "else". Here is the code: snipsave.com/user/profile/balintsipos#8258 I used a normal lookup for the defaults. I hope thats alright. – Balint Jul 8 '14 at 10:01
0

-- OR -- You could do this, which is a little more simple:

SET @studyloccorr = Lookup("SFdataCorr_StudyWhere", @prefix_lang, "StudyWhere", @studyloc)

IF Empty(@studyloccorr) THEN
  SET @studyloccorr = "default value"
ENDIF
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.