Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
gines_rueda
Contributor III
Contributor III

Expression error using an if/pick match with 2 aggr cases

Hi,

I have a table with:

Dimension: [MainCcy] (has 2 values 'USD', 'GBP')

Expression:

pick

(

       match

       (

            [MainCcy],

            'USD',

            'GBP'

       ),

       SUM(AGGR(SUM([Amount]), [Ccy ISO]) * [Rate To USD]),

       SUM(AGGR(SUM([Amount]), [Ccy ISO]) * [Rate To GBP])

)

[Amount] is related with [Ccy ISO] and  [Rate To GBP]/[Rate To USD] but no with [MainCcy] in the data model.

If I replace the sum aggr funtions for numbers or justs sums it works, but the AGGR funtions produce something that only the formula for the first MainCcy is being shown the second formula in the column is empty.

Do you know why this is happening?

Could you give me a solution?

Thanks.

Ginés.

12 Replies
swuehl
MVP
MVP

Why do you need adavanced aggregation here?

I would try without advanced aggregation aggr() function, but if you need, try with NODISTINCT qualifier:

  SUM(AGGR( NODISTINCT SUM([Amount]), [Ccy ISO]) * [Rate To USD]),

  SUM(AGGR(NODISTINCT SUM([Amount]), [Ccy ISO]) * [Rate To GBP])

gines_rueda
Contributor III
Contributor III
Author

NODISTINCT isn't working, escuse me but I haven't explained myself clearly.

I have amounts with serveral CCy's and what I need is the sum of the amounts in 2 consolidated currencies (GBP, USD).

Then I have a Rate to USD and Rate to GBP realted to the currencies to made that conversion.

So I need to multiply each amount for this rate depending on the dimension.

tresesco
MVP
MVP

Not sure if understood right.

It seems that, you are summing for all, may be it would be simpler :

pick

(

       match

       (

            [MainCcy],

            'USD',

            'GBP'

       ),

       SUM([Amount] * [Rate To USD]),

       SUM([Amount] * [Rate To GBP])

)

swuehl
MVP
MVP

Your dimension MainCcy is not related to the fact table in any way in your data model, right?

So you want to calculate the same sum of amounts in for both dimension values, just multiple with different rates at the end?

I am not sure I understand what you are trying to achieve, could you upload a small sample application with some mock up data and the desired result?

gines_rueda
Contributor III
Contributor III
Author

Not exactly,

Lets say I have 10 amounts, 3 in EUR, 3 in USD and 4 in GBP.

And I have a relation between ISO Ccy and with [Rate to USD] and [Rate GBP].

So what I whant is the sum of the 10 amounts converted to USD in the first column and converted to GBP in the second.

In order to give you more information I have in the same table  [Amount] and [CCy ISO] fields, then I have another table with the Currencies information [CCy ISO], [Rate to USD], and [Rate to GBP].

And MainCCy is not relate with anything.

gines_rueda
Contributor III
Contributor III
Author

I have tried this but it's getting me so much biger amount that I was expecting.

I think because is not multiplying correctly or doing the sum.

In order to give you more information I have in the same table  [Amount] and [CCy ISO] fields, then I have another table with the Currencies information [CCy ISO], [Rate to USD], and [Rate to GBP].

And MainCCy is not relate with anything.

tresesco
MVP
MVP

Make sure that [CCy ISO] field has unique values in Currency info table.

gines_rueda
Contributor III
Contributor III
Author

Done, still the same erros in both approaches.

tresesco
MVP
MVP

Try to create a sample qvw and post, see: Preparing examples for Upload - Reduction and D... | Qlik Community


And explain your expected output there.