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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sub-total

I am havinf the following formula.

If(Sum({<Year={'$(=Max(Year))'}>} [Amount (LCY)]) > 0 AND Sum({<Year={'$(=Max(Year)-1)'}>} [Amount (LCY)]) = 0 AND Sum({<Year={'$(=Max(Year)-2)'}>} [Amount (LCY)]) = 0, (Sum([Amount (LCY)])))

I am not getting sub-total and count of the above in Qlik sense KPI..

Can anyone modify and provide revised formula such that it displays count and sum total

7 Replies
sunny_talwar
MVP
MVP

You may need to do something like this:

Sum(Aggr(YourExpression, YourDimensions)

jonathandienst
Partner - Champion III
Partner - Champion III

If you are in a straight table, change the sum method on Properties | Expressions to sum of rows and/or count of rows.

To get sum fo rows in a pivot table, you will need something like:

Sum(Aggr(

  If(Sum({<Year={'$(=Max(Year))'}>} [Amount (LCY)]) > 0 AND Sum({<Year={'$(=Max(Year)-1)'}>} [Amount (LCY)]) = 0 AND Sum({<Year={'$(=Max(Year)-2)'}>} [Amount (LCY)]) = 0, (Sum([Amount (LCY)]))),

  <table dim1>, <table dim2>, ...))

Replace <table dim1>, ... with a comma separated list of all the pivot table dimensions.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks,

but can you please re-write the code. I am getting syntax error.

Not applicable
Author

Can anyone help me with the expression.

I am getting syntax error.

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this expression

=Sum(Aggr(If(Sum({<Year={'$(=Max(Year))'}>} [Amount (LCY)]) > 0

  AND Sum({<Year={'$(=Max(Year)-1)', '$(=Max(Year)-2)'}>} [Amount (LCY)]) = 0 , Sum([Amount (LCY)])), DimensionName))

Not applicable
Author

Jagan,

Thanksa lot.

last question in this thread

when I select a year,  I also want the previous year's data and next years data.

I added -1 and +1 after the years.

But I am not getting it.

Can you help me with the code.

jagan
Partner - Champion III
Partner - Champion III

HI,

Try like this

Sum({<Year={'>=$(=Max(Year) - 1)<=$(=Max(Year) + 1)'}>} [Amount (LCY)])



Regards,

Jagan.