Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
07mishin
Contributor II
Contributor II

WildMatch(Peek())

Good evening. Please, help me.

My code:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

[data]:
Load * Inline [
INDEX_EXCEL_TABLE, City, postalAddress
111, 'A', 111
222, 'B', 222
333, 'A', 333
];

[New data]:
load *,
if(WildMatch(postalAddress, Peek(INDEX_EXCEL_TABLE, 1, 'data'))=1, City) as New_City
Resident [data];

Drop Table [data];
Exit Script;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

My result in data-model:

INDEX_EXCEL_TABLE City postalAddress New_City
111 A 111 -
222 B 222 B
333 A 333 -

 

But I need all values in New_City.

Thanks!!!

1 Solution

Accepted Solutions
Or
MVP
MVP

If there's some sort of fixed way to get the index through text functions - in the example, you could use Mid(postalAddress,4,3) or KeepChar(postalAddress,'1234567890') - I would recommend using that approach for simplicity.

If you absolutely need to combine a mapping load with a partial string match, have a look at https://qlikviewcookbook.com/recipes/download-info/mapping-with-wildcards/ , https://community.qlik.com/t5/QlikView-App-Dev/Mapping-with-a-table-using-wildcards/td-p/1511935 , or any number of threads related to  mapping with wildcards.

View solution in original post

3 Replies
Or
MVP
MVP

 Peek(INDEX_EXCEL_TABLE, 1, 'data') means "Check the value of INDEX_EXCEL_TABLE in the second line of the 'data' table", so you're always comparing that value (which is 222) to PostalAddress, and as a result, it's only evaluating to true in the second line. Since I don't understand what you're trying to do here, though, I can't suggest as to how you might fix it. Typically you would use RowNo() or RecNo() in a Peek statement if you're looking for the next line in the table.

07mishin
Contributor II
Contributor II
Author

Thank you. I'll try to explain 🙂 I have 2 tables. One table is a directory. The second table is a table of values.

First:

INDEX City
111 'NY'
222 'RUS'

 

 Second:

postalAddress
aaa111bbb
aaa222bbb

 

I need to look for a substring [INDEX] in a row [postalAddress], if a substring is found, then insert a value [City] in a new column in Second table.

Or
MVP
MVP

If there's some sort of fixed way to get the index through text functions - in the example, you could use Mid(postalAddress,4,3) or KeepChar(postalAddress,'1234567890') - I would recommend using that approach for simplicity.

If you absolutely need to combine a mapping load with a partial string match, have a look at https://qlikviewcookbook.com/recipes/download-info/mapping-with-wildcards/ , https://community.qlik.com/t5/QlikView-App-Dev/Mapping-with-a-table-using-wildcards/td-p/1511935 , or any number of threads related to  mapping with wildcards.