Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Announcement: Certain actions are currently causing a Page Not Found error. This is a known issue and we are working with the platform vendor to investigate and resolve it.
Highlighted
Emma
New Contributor II

Adding a column in Script

Hi all,

My query is pretty straight forward, I have the following table as input and would like to add a colum in the script while loading data in Qlikview.

(Picture of data below) Please note that the input data cannot be changed at the source.

INPUT DATA:

Capture.JPG

My goal is to add a column in the script that will rewrite the same description IF the Count =0 for every unique ID.

The data should look like this:

Capture3.JPG

The nulls in New_Column can be replaced by something else like a number as long as it's different from the Description value.

Thank you.

3 Replies
arpitkharkia
Contributor III

Re: Adding a column in Script

Add the following column

if(count=0,Description)  as  New_column

 

Emma
New Contributor II

Re: Adding a column in Script

Hi Arpitkharkia

Thanks for the reply. Apologies I forgot to mention a critical detail. Some of the data looks like the following:

Capture1.JPG

Your approach will make it look like this:

Capture.JPG

Instead of the desired result, which is this:

Capture3.JPG

If there is a method to replace all the "Count" that have 0 with the first "Description" that has a count=0, that would solve the issue.

Many thanks

arpitkharkia
Contributor III

Re: Adding a column in Script

im not sure how all of the data looks like and how new data will look in the future, but what i can think of now is to create a mapping file with three columns, description, count and new column.

You manually add the details of the new column accordingly and left join it to the main table.

I hope this makes sense Emma, else please let us know.

Regards,

Arpit