Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have data in the following formats:-
There are roughly 50 ATB codes
ATB Code | Description | Compatible CIB Codes |
---|---|---|
1 | Central | 0111-6423, 7012-7018, 6603 |
2 | Local | 0111-6423, 7012-7018 |
+
There are roughly 500 CIB Codes
CIB Codes | Desc |
---|---|
0111 | Desc 1 |
0112 | Desc 2 |
0123 | Desc 3 |
0124 | Desc 4 |
I want to create a row based table of acceptable ATB and CIB combinations that would end up in this format:-
ATB Code | CIB Codes |
---|---|
1 | 0111 |
1 | 0112 |
1 | 0123 |
1 | 0124 |
Is this doable using Qlikview? If so what script commands would one use?
Thanks
Stuart
Hi Stuart,
I think the attached should do what you are looking for.
Hope that helps
Joe
The ApplyMap function is used for mapping any expression to a previously loaded mapping table. The syntax is:
applymap('mapname', expr [ , defaultexpr ] )
where:
mapname is the name of a mapping table that has previously been created through the mapping load or the mapping select statement (see Mapping). Its name must be enclosed by single, straight Quotation Marks in Scripting.
expr is the expression, the result of which should be mapped.
defaultexpr is an optional expression which will be used as a default mapping value if the mapping table does not contain a matching value for expr. If no default value is given, the value of expr will be returned as is.
Examples:
// Assume the following mapping table:
map1:
mapping load * inline [
x, y
1, one
2, two
3, three ] ;
ApplyMap ('map1', 2 ) returns ' two'
ApplyMap ('map1', 4 ) returns 4
ApplyMap ('map1', 5, 'xxx') returns 'xxx'
ApplyMap ('map1', 1, 'xxx') returns 'one'
ApplyMap ('map1', 5, null( ) ) returns NULL
ApplyMap ('map1', 3, null( ) ) returns 'three'
The MapSubstring function is used to map parts of any expression to a previously loaded mapping table. The mapping is case sensitive and non-iterative and substrings are mapped from left to right. The syntax is:
This function can be used for mapping parts of any expression on a previously loaded mapping table. The mapping is case sensitive and non-recursive. The substrings are mapped from the left to the right. Mapname is the name of a mapping table previously read by a mapping load or a mapping select statement (see Mapping). The name must be enclosed by single straight quotation marks. Expr is the expression whose result should be mapped by substrings.
Examples:
// Assume the following mapping table:
map1:
mapping load * inline [
x, y
1, <one>
aa, XYZ
x, b ] ;
MapSubstring ('map1', 'A123') returns 'A<one>23'
MapSubstring ('map1', 'baaar') returns 'bXYZar'
MapSubstring ('map1', 'xaa1') returns 'bXYZ<one>'
QlikView 11.20 SR6
Hi Stuart,
If you just need to have data from table to be linked with all the data from table 2 then concatenate would do, But what the mapping for 2 here? I.e how you identify 1 showed be linked with 0111,0112,0113 etc ?? and even 2 data show be linked with the 0111,0112,0113 etc? if that is the case then simply concatenate or if their is any condition please specify that mapping condition
Avinash that is the part I am struggling with.
We have one text string that says ATB 1 is allowed to use CIB codes 0111-6423.
Within the range 0111-6423 there are actually 290 CIB codes.
The target, for example, is to create the mapping table with 290 lines for ATB 1
can you share a sample data set, you could probably apply an if condition checking if the mapping exists or not
IF you simple need to have create column for the records in CIB code then just use concatenate between those to tables that will create a row for each record in the ATB with a record in the CIB
Hope this solve's the problem
have attached a sample dummy data set
did you tired with concatenation
I cant see how that will work as I need to get the table in the following format:-
ATB Code | CIB Codes |
---|---|
1 | 0111 |
1 | 0112 |
1 | 0123 |
1 | 0124 |
Try this:
_ATB:
LOAD ATB,
[Compatible ATB Codes],
SubStringCount([Compatible ATB Codes], ',') + 1 as Subfields
FROM
[sample data set.xlsx]
(ooxml, embedded labels, table is [ATB Codes]);
MaxSubfields:
LOAD
max(Subfields) as maxSubfields
RESIDENT _ATB;
Let vMaxSubfields = peek('maxSubfields', -1);
DROP TABLE MaxSubfields;
for n = 1 to vMaxSubfields
TRACE $(n);
ATB:
LOAD
ATB,
Subfield([Compatible ATB Codes], ',', $(n)) as CompatibleATBCode,
$(n) as loop
RESIDENT _ATB
WHERE $(n) <= Subfields
;
next n
DROP TABLE _ATB;