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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help with the Aggr function

I am having an issue trying to get a formula I put in a textbox to match up to a sum of rows in a chart.  As you can see from the image below, my sum of rows is $13,705,160.52.

Here is the formula I'm using:

=if(Year= $(=Max(Year)) and num(Month)= $(=Max(Month)) and ActiveEmployeeYN = 1 ,[Annual Salary])

In the green textbox above, I'm using the exact same formula but add sum and formatting:

=num(sum(if(Year= $(=Max(Year)) and num(Month)= $(=Max(Month)) and ActiveEmployeeYN = 1 , [Annual Salary])),'$#,##0.##')

Analytics.jpg

Can someone please tell me what I'm doing wrong?  I believe I need to use the Aggr function, but anytime I use it, my value is 0.  Thanks for your help

18 Replies
MK_QSL
MVP
MVP

Can you provide 5-10 lines of sample data please?

Not applicable
Author

I'm not sure I understand what you want.  The chart on the bottom right is what I'm using for the data.

Not applicable
Author

Here is a spreadsheet that includes the data

MK_QSL
MVP
MVP

Try below

=SUM({<Month = {'$(=Max({<Year = {'$(=Max(Year))'}>}Month))'},ActiveEmployeeYN = {'1'}>}[Annual Salary])

Not applicable
Author

it's showing an error in the expression window, and showing a 0 value in the text box.

error.jpg

MK_QSL
MVP
MVP

Create an Inline Table as below

Load * Inline

[

Month, MonthNo

Jan, 1

Feb, 2

Mar, 3

];

Upto Dec 12 and use MonthNo instead of Month...

Let me know if still not working for you.

Not applicable
Author

Same issue,  MonthNo is still underlined in redscript.jpg

MK_QSL
MVP
MVP

=Month = {"$(=Max({<Year = {'$(=Max(Year))'}>}MonthNo))"}

Not applicable
Author

I still get an error.  I've attached the qvw.  I hope this helps