Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to add calculated field in Qlikview.

How can we create calculated feild in Qlikview?

6 Replies
mdmukramali
Specialist III
Specialist III

Dear Shruti,

in the back end script level you can create the calculated field like suppose

Sal+Comm as TotalSalary

if your looking for something else then please attach the sample file with your requirement.

Thanks,

Mukram

Not applicable
Author

if you want to add calculated dimension as period like as

go to dimension->click on add calculated dimension-> write expression as

Left(Month,3)&'-'&Right(Year,2)

and label as Period and add expression in expression tab

hope this give you an idea to add calculated field

sujeetsingh
Master III
Master III

Calculated fields can be added in two ways:

1- UI as calculated dimension or  as ecpressios

2- In load script using if,cases, and other function of qlikview.

For example

Table1:

ID, Sales

1   , 12

2   , 15

3   , 19

Now you can add a calculated flag as

Data:

load ID,Sales

,if(Sales<=15,'Met Target','Bad Performance') as Status

resident Table1;

Drop table1;

Not applicable
Author

Hi Shruti

May be you would like to read this-

http://community.qlik.com/blogs/qlikviewdesignblog/2014/04/08/calculated-dimensions

Regards

Saurabh

Not applicable
Author

Hi Shruthi,

You can add calculated field in two place of Qlikview, you can do it in chart, for dimension.

or you can add a calculated field in script.

For script, if your calculated field don't require a group by clause then you can add a line of the field and apply a function like that

load

orderdate,

year(orderdate) as Year_ORDERDATE,

month(orderdate) as Month_ORDERDATE,

cost,

profit

from t1;

and if you want to use some aggreagation function then you can use a script like

load Month_ORDERDATE,

sum(cost) as total_monthlycost,

sum(cost) as total_Yearlycost

From t1;

Note: remember all qlikview function doesn't work with SQL select statment, then you can use the preceeding load functionality.


If you dont want to do these calculation in the script then you can add a calculate dimension in qlikview chart,

this option is present in the dimension tab.

add calculated dimension

for example you can use =month(orderdate) there.

But its good if you do these calculation in script, because every time the chart run Qlikview calculate everything, it makes the performance little slow.

For group by calculation, its wise to use calculation in chart. anyway it depends on data and situation



With Regards

Harshita Gaur



Not applicable
Author

Hi Shruti,

It's very simple:

Try like this:

Table:

Employee ID, EmpSal, [Emp Special Allowances]

1, 100, 200

2, 200, 100

3, 100,150

Take Chart like Straight or any Bar Chart

Step 1: Load Data

Step 2 : Select New Sheet Object -> Chart -> Bar Chart

Step 3: Choose Dimension -> Add Calculated Dimension -> Write like:- Empsal + [Emp Special Allowances]  as Net Salary

Step 4:  Expression as EmpId

Step 5: Finish

You can get best  solutions.

Ramya.