Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum with aggr ?

Hello Qlikview community,

how can i make a table outside a sum of a custom formula column?

This formula-based column is calculated by two dimensioned fields. My intention is to add up this column outside.

Some users recommend this formula in the forum. =sum(aggr(sum([DATA_Imps]) * UnitPrice, UnitPrice))

But on closer look is not on the calculation. See snapshot.

What thinking mistake am I doing?

Thank you!

Best regards,

1 Solution

Accepted Solutions
Not applicable
Author

First, you need to replace Einheitspreis in the Text Box expression. Einheitspreis is an expression in the chart and has no meaning outside of the chart. Use the formula for Einheitspreis instead: SAL_OPPORTUNITYLINEITEM_UnitPrice.

Then Aggr() around your existing expression with the dimensions in your chart:

=Sum(Aggr(
if( index(concat([HEL_BANNER_Banner]),'lock')>=1,
(sum([HEL_DATA_Imps mit Defaults])*0.5),(sum([HEL_DATA_Imps mit Defaults])) ) *
SAL_OPPORTUNITYLINEITEM_UnitPrice
,SAL_OPPORTUNITY_Name, SAL_PRODUCT_Name))


Place that into a Text Box and you get the 699687 you are looking for. Sample attached.

View solution in original post

15 Replies
Not applicable
Author

You need to replace Unit Price in the Aggr() function with the dimensions in your chart. Think of Aggr() as a Group By in SQL. You are grouping by unit price and then summing the values.

It looks like your chart has three dimensions, so you need:

=sum(aggr(sum([DATA_Imps]) * UnitPrice, OPP, Einheitspreis, Produkt))


Not applicable
Author

Hello NMiller,

can not realize your recommendation! Is there no other way to take values directly from the chart?

Thank you !


Best regards,

Not applicable
Author

Hi,

unfortunately I can not from a formula-based form field a final sum. Super Angry Sad

Explanation:

My table is calculated in every line the product of (quantity * price). Receives the product name (Produktitem) the content of 'lock', so the amount divided by 2. Otherwise not.

In sum, should appear as expected, a value of € 699,687.28.

Unfortunately I did not manage to make a sum of these lines.
I've uploaded my qvw.

Thanks for any help


Best Regards,

Not applicable
Author

First, you need to replace Einheitspreis in the Text Box expression. Einheitspreis is an expression in the chart and has no meaning outside of the chart. Use the formula for Einheitspreis instead: SAL_OPPORTUNITYLINEITEM_UnitPrice.

Then Aggr() around your existing expression with the dimensions in your chart:

=Sum(Aggr(
if( index(concat([HEL_BANNER_Banner]),'lock')>=1,
(sum([HEL_DATA_Imps mit Defaults])*0.5),(sum([HEL_DATA_Imps mit Defaults])) ) *
SAL_OPPORTUNITYLINEITEM_UnitPrice
,SAL_OPPORTUNITY_Name, SAL_PRODUCT_Name))


Place that into a Text Box and you get the 699687 you are looking for. Sample attached.

Not applicable
Author

you are my hero Yes

Thank you very much ! Arigato wise Ninja Big Smile

Not applicable
Author

My pleasure. I'm adding the quote, "Arigato wise Ninja," to my business card! Cool

Not applicable
Author

Hi,

I review your aplictation and I think that this is the formula that you need.

=sum(aggr(

if(index(concat([HEL_BANNER_Banner]),'lock')>=1,sum([HEL_DATA_Imps mit Defaults]*0.5),sum([HEL_DATA_Imps mit Defaults]) )

*SAL_OPPORTUNITYLINEITEM_UnitPrice

,SAL_PRODUCT_Name))

Regards,



Not applicable
Author

Hi,

if I want to hold that value, I would like to add this.

sum ({1 <[HEL_DATA_Datum> YEAR] = {$ (GetFieldSelections = ([HEL_DATA_Datum> YEAR]))}>}

It should therefore be considered only when the year changes. All other changes are to be ignored.

I tried that.


=sum( {1 <[HEL_DATA_Datum> YEAR] = {$ (GetFieldSelections = ([HEL_DATA_Datum> YEAR]))}>} Aggr(

if( index(concat([HEL_BANNER_Banner]),'lock')>=1,
(sum([HEL_DATA_Imps mit Defaults])*0.5),(sum([HEL_DATA_Imps mit Defaults])) ) *
SAL_OPPORTUNITYLINEITEM_UnitPrice

,SAL_OPPORTUNITY_Name, SAL_PRODUCT_Name))

But unfortunately without success. Perhaps you have an idea?

Thank you!

Not applicable
Author

You could do something like this:

=sum({1<[HEL_DATA_Datum > YEAR]={"$(=Max([HEL_DATA_Datum > YEAR]))"}>} aggr(

if(index(concat([HEL_BANNER_Banner]),'lock')>=1,

sum({1<[HEL_DATA_Datum > YEAR]={"$(=Max([HEL_DATA_Datum > YEAR]))"}>} [HEL_DATA_Imps mit Defaults])*sum({1<[HEL_DATA_Datum > YEAR]={"$(=Max([HEL_DATA_Datum > YEAR]))"}>} SAL_OPPORTUNITYLINEITEM_UnitPrice)*0.5,

(sum({1<[HEL_DATA_Datum > YEAR]={"$(=Max([HEL_DATA_Datum > YEAR]))"}>} [HEL_DATA_Imps mit Defaults])*sum({1<[HEL_DATA_Datum > YEAR]={"$(=Max([HEL_DATA_Datum > YEAR]))"}>} SAL_OPPORTUNITYLINEITEM_UnitPrice)))

,SAL_PRODUCT_Name))

It work with 2011, but has some problems with 2010, maybe you can check the detail