Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating a column in the script

Hi friends:

Can you please help me with this

I have a column in the table called Category. It has 2 values - Cat1,Cat2

In a list box for Category i get 2 values like

Category

Cat1

Cat2

When user selects Cat1, i perform a calcualtion on this like

If Category = 'Cat1', revenue*100

When user selects Cat2, i perform a calcualtion on this like

If Category = 'Cat2', revenue*200

i don't have a 3rd category in the table , but users want to list 3rd category in the list box , which should be in the list box of Category

and should look like

Category

Cat1

Cat2

Cat3

When user selects Cat3, i should perform a calculation on this like

If Category = 'Cat3', (revenue*100) + (revevnue*200)

I can create Cat3 as a separate list box, but they want Cat3 should be under the same list box so that they can select only one among Cat1,Cat2 and Cat3.

4 Replies
Gysbert_Wassenaar

You could add this to the script:

Categories:

load * inline [

Category

Cat1

Cat2

Cat3

];

That way your Category field will have the three values Cat1, Cat2 and Cat3.


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks for your response.

That is correct using Inline i can get 3 categories but how they will associate to my fact table.


Not applicable
Author

Hi Chand,

I hope the below Raw script will help you.

You can fine tune the attached application based on your requirements.

Master:

LOAD now() as Reload_Time

    ,RowNo() as Rno

    ,if(mod(RowNo(),12)=0,12,mod(RowNo(),12)) as Month

    ,round(Rand()*100,1.00,2) as Revenue

    ,'CAT '& num(mod(RowNo(),3)+1) as Category

AutoGenerate (100);   

Formula:

LOAD * INLINE [

    Category, QV_Formula

    CAT 1, Revenue*100

    CAT 2, Reveue*200

    CAT 3, Revenu*300

];

Not applicable
Author

Ajay:

Thanks for the example.

In your example , your master table already have 3 categories Cat1,Cat2 and Cat3

My problem is that my fact table does not have category 3 but have a amount which i can use if i have Cat3.

So i need to create a value in the existing Category and display it in the list box and when user select Cat3 perform calculation.