Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am using Match function to retrieve a certain result which is working fine in the UI, but when I use the same in script, I am not getting the same result. I have used the following expression.
If(Match(DISMM,'VR','V1','ZA','ZD')=0,'Not_Stocked','Not_ClosestPlant')
DISMM is a field that contains the values,VR,V1,ZA,ZD,ND,PD,X0,Z1. When I used the expression in a list box under Expression. When I select Stocked or Not_ClosestPlant,the resultant DISMM values are getting selected, but with script, that is not happening.Can anyone please help.
Yes, If there are %VBELNPOSNRs that have only one ReasonCode then I would expect those to be filtered out when you select the other ReasonCode.
If you create a straight table with RCode.ReasonCode as the dimension and count(DISTINCT [%VBELNPOSNR]) as the measure and clear all filters then does it show different counts against '9-...' and '10-...'?
Would you be able to share a sample where it isn't working?
Seems to be working here using this script:
Table:
LOAD *,
If(Match(DISMM,'VR','V1','ZA','ZD')=0,'Not_Stocked','Not_ClosestPlant') as New_Dim;
LOAD * Inline [
DISMM
VR
V1
ZA
ZD
ND
PD
X0
Z1
];
But the script is executing without failure and the field produced contains both Not_Stoked and Not_ClosestPlant?
If that is the case I suspect that wherever you're calculating this new field it is not correctly associated to DISMM in the data model. You could verify this in the table viewer.
Hi Sunny,
Here is the complete script that I have been using. The bold part is where I am having the issue.
RCode:
Load %VBELNPOSNR,
if(PSTYV='TAB' OR PSTYV='TABN','0 – CrossDock',If(LIPS_WERKS=[WH Code 1],'1 – Cust_Geo_Prime',if(LIPS_WERKS='8041' or
LIPS_WERKS='8042'or LIPS_WERKS='8043'or LIPS_WERKS='8044' or LIPS_WERKS='8615','2 – Sci_Ed',
if(LIPS_WERKS='8031' or LIPS_WERKS='8032','3 – Furniture',
if(LIPS_WERKS='8033' or LIPS_WERKS='8035','4 – Export',
if(LIPS_WERKS='8036' or LIPS_WERKS='8037','5 – Seradigm',if(LIPS_WERKS <> [WH Code 1] AND LIPS_WERKS <> [WH Code 2] AND
LIPS_WERKS <> [WH Code 3] and LIPS_WERKS <> [WH Code 4] and LIPS_WERKS <> [WH Code 5] and
LIPS_WERKS <> [WH Code 6] and
LIPS_WERKS <> '8031' and LIPS_WERKS <> '8032' and LIPS_WERKS <> '8033' and LIPS_WERKS <> '8036' and LIPS_WERKS <> '8037'
and LIPS_WERKS <> '8041' and LIPS_WERKS <> '8042' and LIPS_WERKS <> '8043' and LIPS_WERKS <> '8044'
and LIPS_WERKS <> '8615' ,'6 – AWS_Override',if(%KNMTWERKS=LIPS_WERKS,'7 – Per_InfoRec',if(CLSTK_PLANT=LIPS_WERKS,'8 – Closest_StkPlnt',
if(Match(DISMM,'VR','V1','ZA','ZD')=0, '9-Not_Stocked',
'10 – Not_Closest_StkPlnt'
)))))))))) AS ReasonCode
Resident Delivery;
I have attached the selections screenshots of the Reason codes and their possible selections of DISMM when the above'IF' statement expression is used in UI and script. It shows that the script loaded expression is not selecting the relevant DISMM values.
From your screenshots, it looks to me like the script created "ReasonCode=Not_Stocked" is associating with the relevant DISMM values,
Is the question why the listbox created with <Expression> makes actual selections (green) in the DISMM field and the script field does not? The selection is a side effect of using <Expression>. Normal behavior of selecting one field is to associate, not select other fields. You can modify this behavior, see:
Scoping Selections with Aggr() | Qlikview Cookbook
-Rob
Hi Rob,
I have attached the UI screenshot only to refer that the possibility of the selections is correct in the UI whereas in the script it is not giving the possible values in correct format which usually should happen by showing in White when loaded from script. My requirement to show to the selections even when loading through script is to get the correct count of keys associated to these selections. Only when the possible selections are made am I getting the correct count of the required keys which is not happening when loaded through Script.
Does your listbox expression contain the same large if() as the script? And they are returning different results?
-Rob
I think we would need to look at the data model and at the script sequence to understand if the two large if() statements are really equivalent.
Yes