加载和应用映射中的 Qlikview CASE 语句或子查询
Qlikview CASE statement or subquery inside a load and apply map
有一个内联加载,我必须将歌曲 ID 添加到豁免列表中:
Exemptsongs:
Load * Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
];
Exemptsongsmap:
Mapping LOAD
[Song ID],'Exempt' as [Exempt songs exempt]
Resident Exemptsongs;
DROP Table Exemptsongs;
然后在需要时将其加载到播放列表的其他位置 table。
我想做的也是将特定用户添加的歌曲 ID 添加为豁免,但只有当该用户添加时,其他任何人添加时它们才不会豁免(除非在上述豁免名单)。
我在想(伪)是这样的:
Exemptsongs:
Load * Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
(SELECT SongID FROM Songs WHERE addedbyuser = 'MATT')
];
Exemptsongsmap:
Mapping LOAD
[Song ID],'Exempt' as [Exempt songs exempt]
Resident Exemptsongs;
DROP Table Exemptsongs;
然后在加载播放列表时,applymap 部分当前是这样的:
ApplyMap('Exemptsongsmap',[Playlist ID],'Non-exempt') as [Exempt songs exempt],
但是想不出如果songid也是别人加的,怎么不让songid免除。
例如
如果用户 matt 添加了歌曲 ID 12345 并且另一个用户添加了它,我希望它在 matt 添加时在播放列表中被豁免。
错误 1:
Syntax error, missing/misplaced FROM:
Exemptsongs:
Load [Song ID]& as UniqueID Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
]
Exemptsongs:
Load [Song ID]& as UniqueID Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
]
错误 2:
Field not found - <Song ID>
load [Song ID]&addedbyuser as UniqueID
from Songs
where addedbyuser='Matt';
错误 3:
Table not found
Exemptsongsmap:
Mapping LOAD Distinct
UniqueID,'Exempt' as [Exempt songs exempt]
Resident Exemptsongs
错误 4:
Table not found
DROP TABLES statement
然后我们还没有更改的其他多个错误...
您需要创建一个唯一的 Id,它是 SongId 和 addedbyuser 连接在一起的。 chr(39) 的东西只是为了创建一个列表,每个值都为 'value'.
USERS:
load concat(distinct addedbyuser,chr(39)&','&chr(39)) as userids from Songs;
let vList = chr(39)&fieldvalue('userids',1)&chr(39);;
for each a in $(vList)
ExemptSongs:
Load [Song ID]&$(a) as UniqueID;
Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
];
next a
//Allow auto concatenate of these tables
load [Song ID]&addedbyuser as UniqueID
from Songs
where addedbyuser='Matt';
Exemptsongsmap:
Mapping LOAD distinct
UniqueID,'Exempt' as [Exempt songs exempt]
Resident Exemptsongs;
DROP Table Exemptsongs;
然后最后
ApplyMap('Exemptsongsmap',[Playlist ID]&addedbyuser,'Non-exempt') as [Exempt songs exempt],
有一个内联加载,我必须将歌曲 ID 添加到豁免列表中:
Exemptsongs:
Load * Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
];
Exemptsongsmap:
Mapping LOAD
[Song ID],'Exempt' as [Exempt songs exempt]
Resident Exemptsongs;
DROP Table Exemptsongs;
然后在需要时将其加载到播放列表的其他位置 table。
我想做的也是将特定用户添加的歌曲 ID 添加为豁免,但只有当该用户添加时,其他任何人添加时它们才不会豁免(除非在上述豁免名单)。
我在想(伪)是这样的:
Exemptsongs:
Load * Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
(SELECT SongID FROM Songs WHERE addedbyuser = 'MATT')
];
Exemptsongsmap:
Mapping LOAD
[Song ID],'Exempt' as [Exempt songs exempt]
Resident Exemptsongs;
DROP Table Exemptsongs;
然后在加载播放列表时,applymap 部分当前是这样的:
ApplyMap('Exemptsongsmap',[Playlist ID],'Non-exempt') as [Exempt songs exempt],
但是想不出如果songid也是别人加的,怎么不让songid免除。
例如
如果用户 matt 添加了歌曲 ID 12345 并且另一个用户添加了它,我希望它在 matt 添加时在播放列表中被豁免。
错误 1:
Syntax error, missing/misplaced FROM:
Exemptsongs:
Load [Song ID]& as UniqueID Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
]
Exemptsongs:
Load [Song ID]& as UniqueID Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
]
错误 2:
Field not found - <Song ID>
load [Song ID]&addedbyuser as UniqueID
from Songs
where addedbyuser='Matt';
错误 3:
Table not found
Exemptsongsmap:
Mapping LOAD Distinct
UniqueID,'Exempt' as [Exempt songs exempt]
Resident Exemptsongs
错误 4:
Table not found
DROP TABLES statement
然后我们还没有更改的其他多个错误...
您需要创建一个唯一的 Id,它是 SongId 和 addedbyuser 连接在一起的。 chr(39) 的东西只是为了创建一个列表,每个值都为 'value'.
USERS:
load concat(distinct addedbyuser,chr(39)&','&chr(39)) as userids from Songs;
let vList = chr(39)&fieldvalue('userids',1)&chr(39);;
for each a in $(vList)
ExemptSongs:
Load [Song ID]&$(a) as UniqueID;
Inline [
Song ID
45875
65463
43785
90347
23456
89438
16745
];
next a
//Allow auto concatenate of these tables
load [Song ID]&addedbyuser as UniqueID
from Songs
where addedbyuser='Matt';
Exemptsongsmap:
Mapping LOAD distinct
UniqueID,'Exempt' as [Exempt songs exempt]
Resident Exemptsongs;
DROP Table Exemptsongs;
然后最后
ApplyMap('Exemptsongsmap',[Playlist ID]&addedbyuser,'Non-exempt') as [Exempt songs exempt],