RobWunderlich / Qlikview-Components

A library for common Qlikview Scripting tasks
197 stars 99 forks source link

Qvc.CreateWildMapExpression optional parameter for when return value is null #66

Closed qvsdeveloper closed 7 years ago

qvsdeveloper commented 7 years ago

I would like an enhancement to the sub Qvc.CreateWildMapExpression so that I could pass a default string parameter instead of the function returning a Null value.

like: CALL Qvc.CreateWildMapExpression(vMapExpr, 'WildMapTable', 'Value When Null);

I'm assuming that passing an optional parameter would be faster that using an if statement like: if(isnull($(vMapExpr([%WildMapTable]))) , 'Not Applic.' , $(vMapExpr([%WildMapTable])))

veglar commented 7 years ago

I do not see the need of this since it could be solved with the current setup.

I put a star (*) with an default value as the last row in my wildmapping table when I want a default value.

The wildmaptable is evaluated from top to bottom so a last row with star (*) will catch everything that is not caught earlier in the wild map table.

RobWunderlich commented 7 years ago

The "*" will not map a null() because this routine uses the WildMatch() string function to simulate "wildcard mapping". Implementing an optional value for nulls would use the same kind of if() as you propose above and therefore no faster. I would code it like: if(len(myval)=0, 'NA', $(vMapExpr(myval))

My feedback is that you can clearly do this with your own if() and there is no need or advantage to adding it Qvc.CreateWildMatchExpression. Comments?

qvsdeveloper commented 7 years ago

Now that I understand that the wildmaptable is evaluated from top to bottom I see that as veglar states above it is solved with the current setup. I was trying to use it like the applymap function.