Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
marcvw
Partner - Contributor III
Partner - Contributor III

load script for column

Good day all, 

I try to create a script for a column named 'allotment/garantee'. We have a field called 'Key_service' whereby we have received several numbers for. These numbers should be named 'garantee'. All the rest should be named 'allotment'. 

I have the following script:

Load
KEY_Service,
if(
Match(KEY_Service, '123', '456', '789'),
'garantee',
'allotment') as [allotment/garantee]
Inline
[
KEY_Service
123
456
789
];

At this stage I can only see the values named 'garantee' however the not specified numbers appear as '- ' instead of 'allotment'

How can I resolve this?

Labels (4)
2 Solutions

Accepted Solutions
BrunPierre
Partner - Master
Partner - Master

Without remodeling, you'd need to add the condition mentioned above in every table where KEY_Service field exist throughout the model.

View solution in original post

marcus_sommer

Beside applying the matching in each table-load you may depending on the data-set and the requirements also remove the records of these NULL keys. This is for example a quite common approach to filter dimension-tables against the fact-tables and not loading long outdated products, staff and similar since the company start.

If this isn't suitable for your scenario you should really consider a change of the data-model because your NULL experience here means that there are missing key-values between the various tables - and this means further you will never be able to display all data together at the same time. 

View solution in original post

11 Replies
BrunPierre
Partner - Master
Partner - Master

Your provided script will not assign 'allotment' or '-' because the condition is true for all values.

You can do this to verify the non specified numbers in your actual source table.

LOAD KEY_Service
FROM <Source>
Where Match(KEY_Service, '123', '456', '789') = 0;

Anil_Babu_Samineni

@marcvw -the script works as it should, I can see the input data you have only with 3 values, If you add one more what is coming? any screenshot?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
marcvw
Partner - Contributor III
Partner - Contributor III
Author

Thank you for your response in here. Would it be possible to assign 'allotment' to this column next to garantee? How can I enable this. Appreciate your support in here. 

marcvw
Partner - Contributor III
Partner - Contributor III
Author

Hi Anil, I see the column 'allotment/garantee' and only values 'garantee' for the values provided and '-' for the non-provided values. Instead of '-' I would like to see the 'allotment' value. Can this be accomplished? 

BrunPierre
Partner - Master
Partner - Master

"-" typically indicates that the field has NULL or empty values.

You can adjust your script to handle such values appropriately or replace "-" with a different representation as needed, as in your case "allotment".

If(Match(KEY_Service, '123', '456', '789'), 'garantee',
If(Len(Trim(KEY_Service))= 0, 'allotment', 'allotment')) as [allotment/garantee]

marcvw
Partner - Contributor III
Partner - Contributor III
Author

I've modified the script, see enclosed result. Are there any other ways to reesolve this? Thanks in advance. 

marcus_sommer

Your condition will always return a value of TRUE or FALSE and not NULL unless there is anything which might break the expression which seems not likely in regard to your example but may theoretically happens if there are in reality variables in use and/or further loops or other functions.

This means your NULL will probably come from a different table which also contained the KEY_Service as field.

BrunPierre
Partner - Master
Partner - Master

Based on @marcus_sommer 's explanation, share the data model.

marcvw
Partner - Contributor III
Partner - Contributor III
Author

Data model is attached. Thank you.