Qlik Community

Qlik Sense Data Connectivity

Discussion board where members can learn more about Qlik Sense Data Connectivity.

Not applicable

calculated feild

Hi,

I am trying to import data from a csv file which have is similar to following table:

Data.jpg

This file already contains first five columns of table shown above. I need a calculated field "Sales Amount" which should be calculated like :

Sales Amount = (Qty x Price ) + Postage

But Problem i was facing is that for orders in which there are multiple skus/items for example order id 1002, in which there are two skus/items (i.e S001, S002). Even though customer has paid only $6 Postage it's showing against both items which results into inflating the total "Sales Amount". In excel we can use following formula to resolve the issue and divide the postage equally to all skus/items :

=(C2*D2)+(E2/COUNTIF(A:A,A2))

I am wondering how i can achieve the same in Qlikview dataload editor script, Appreciate if someone can help/guide me.

Thanks

11 Replies
MVP
MVP

Re: calculated feild

May be this

Sum(Qty * Price) + (Postage/Count(DISTINCT TOTAL <OrderID> SKU))

Not applicable

Re: calculated feild

hi,

Thanks for the quick reply do i have to use it in dataload script or create a Master measure using this formula ? i am asking because i tried putting this in dataload script but it does not work, i tried creating master measure using following :

Sum([Quantity] * [Product Price]) + ([Carriage Amount]/Count(DISTINCT TOTAL <[Order ID]> [SKU]))

it works perfectly for data tables but does not work in visualizations(charts) of any kind.

Can you please guide me what I am doing wrong ? 

Thanks

MVP
MVP

Re: calculated feild

What was your dimension in the chart?

Not applicable

Re: calculated feild

Its Dates, (Months & Weeks) mostly.

MVP
MVP

Re: calculated feild

But your sample data doesn't show any date... I am confused... where did date come in from?

Not applicable

Re: calculated feild

Original data consists more than 50 fields, for the sake of simplicity i only used few fields in sample data which i thought would be relevant.

Not applicable

Re: calculated feild

And can you advise how can we do the same in loadscript.

MVP
MVP

Re: calculated feild

I guess I understand that, but the fields which you use in your dimension/expression, I would expect those to show up in the sample data... otherwise what kind of a sample would it be

Not applicable

Re: calculated feild

As requested here is the revised sample data with few of the dimensions:

Sample data.jpg