Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!!!
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.
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.
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.
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.