# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

New Contributor III

Hi,

In our database all products sold have a price, cost, units and VAT amount.

The VAT amount is the total VAT amount for all units sold for that certain product.

Now I wanna add the right portion of VAT in the load script. Is it possible to add this in a load statement?

I wanna calculate the VAT percentage and the add that to both price and cost.

I want to do something like this (written in c# as an example):

If (VatAmount > 0) {

var vatPercentage = ((VatAmount / Units) / Price) + 1; //Get VAT percentage

Price = Price * vatPercentage;

Cost = Cost * vatPercentage;

}

Product:

Code,

Description,

VatAmount,

Units,

Price,

Cost;

1 Solution

Accepted Solutions
MVP

## Re: Calculation in load script

May be this

Product:

Price * vatPercentage as New_Price,

Cost * vatPercentage as New_Cost;

((VatAmount / Units) / Price) + 1 as vatPercentage;

Code,

Description,

VatAmount,

Units,

Price,

Cost;

3 Replies
Esteemed Contributor

## Re: Calculation in load script

Hi,

Product:

Code,

Description,

VatAmount,

if(VatAmount>0, ((VatAmount / Units) / Price) + 1,1) as vatPercentage,

Price * vatPercentage as Final_VAT_amount,

Cost * vatPercentage as Final_VAT_cost,

Units,

Price,

Cost

FROM TABLE...;

I just put 1 on the ELSE to have a minimum of 1% for the VAT %

Try this, just check your calcualations Rules..

Hope it helps

YB

MVP

## Re: Calculation in load script

May be this

Product:

Price * vatPercentage as New_Price,

Cost * vatPercentage as New_Cost;

((VatAmount / Units) / Price) + 1 as vatPercentage;

Code,

Description,

VatAmount,

Units,

Price,

Cost;

New Contributor III

## Re: Calculation in load script

Thanks Sunny, works great!