# New to QlikView

Discussion board where members can get started with QlikView.

New Contributor III

## Sum spend in the right currency

Hi,

I have a problem with defining the right expression in my tables.

I am currently working on an application that shows our spend on different sites.

My problem is that i want to show the spend in the right currency. If fx the application is used in the US, everything will be shown in USD.

Im extracting my data from a table with this information:

In this example, the cost is shown in DKK even though the buy is in EUR.

The problem with my current expression (in red) is this:

=SUM(If(DATAAREAID_Trans='sdx',COSTAMOUNTPOSTED,COSTAMOUNTPOSTED*(EXCHRATE/100)))

DATAAREAID tells me from which site the transactions is coming from. In this example 'sdx' is located in the US, so I want all the numbers to be converted to USD.

COSTAMOUNTPOSTED(Cost in tabel) is the amount of spend in the currency related to the DATAAREAID.

So even though the buy is made in EUR the cost is shown in DKK if the site is located in Denmark and so on.

I have a currencytabel but because the currency is originally made in EUR the spend is calculated from EUR to USD instead of DKK to USD.

I need something that says that:

if DATAAREAID_Trans = 'sdx' then COSTAMOUNTPOSTED

else if DATAAREAID_Trans = 'rme' then COSTAMOUNTPOSTED*(EXCHRATE/100) where EXCHRATE = 'DKK'

I just have no idea on how to get this done so every help would be much appreciated!

Kind regards Nicolai

Tags (3)
18 Replies

## Re: Sum spend in the right currency

Try this?

If(DATAAREAID_Trans = 'sdx', Sum(COSTAMOUNTPOSTED),

If(DATAAREAID_Trans = 'rme', Sum({<EXCHRATE = {"DKK"}>} COSTAMOUNTPOSTED) * (Sum({<EXCHRATE = {"DKK"}>} EXCHRATE) / 100))

OR

If(DATAAREAID_Trans = 'sdx', Sum(COSTAMOUNTPOSTED), Sum({<DATAAREAID_Trans = {"rme"}>} COSTAMOUNTPOSTED) * (Sum({<EXCHRATE = {"DKK"}, DATAAREAID_Trans = {'rme'}>} EXCHRATE) / 100))

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
New Contributor III

## Re: Sum spend in the right currency

Hi Anil,

thank you for your fast reply. it seemed like a good idea but it doesn't work unfortunately. it just sums to zero

## Re: Sum spend in the right currency

When you receive 0 that means, I believe your data model is wrong.

Try these in your text boxes?

1) If(DATAAREAID_Trans = 'sdx', Sum(COSTAMOUNTPOSTED))

2) Sum({<DATAAREAID_Trans = {"rme"}>} COSTAMOUNTPOSTED) * (Sum({<EXCHRATE = {"DKK"}, DATAAREAID_Trans = {'rme'}>} EXCHRATE) / 100)

Then show me the images, Better if you provide sample

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Contributor III

## Re: Sum spend in the right currency

Hello,

You can go with exchange rate table and can convert into single currency. Then go with selection of particular currency which you want to see.

Like

FromCurrency, ToCurrency,rate

USD,USD,1

AUD,USD,0.56

GBP,USD,1.25

Based on selections or join you can divide with value to get value in respective currency or vice versa.

Regards,

ravi

New Contributor III

## Re: Sum spend in the right currency

Its the same unfortunately.

I think its beacuse the exchangerate table is linked to the CURRENCYCODE ?

Contributor III

## Re: Sum spend in the right currency

Can you please try below code?

RateTable:

From,To,Rate

USD,USD,1

AUD,USD,0.56

GBP,USD,1.25

];

Fact:

Product,Currency,Value

A1,GBP,50

B1,GBP,20

A2,USD,30

B2,AUD,40

];

left join

,Rate as CurrencyRate

Resident RateTable;

FactFinal:

Value*CurrencyRate as Value_USD

Resident Fact;

Drop table Fact;

Contributor III

## Re: Sum spend in the right currency

Hello,

Please find attached app for reference.

Regards,

Ravi

New Contributor III

## Re: Sum spend in the right currency

I can't see any attachments?

New Contributor III