Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis for the sum of the current month customers

I have a table like this:

MonthProductCustomers
1/1/2015Product1

412

1/1/2015Product217
12/1/2014Product1398
12/1/2014Product215
11/1/2014Product1375
11/1/2014Product216

I want to make a aggregation that calculates the number of all customers in the most recent month of selected data. Here's what I have so far:

sum({<Month = {$(=Max(Month))}>} Customers)

In this example, I would expect it to return 429 (412+17). This instead returns a null value, and I can't figure out why.  Sorry if I missed something obvious.

14 Replies
Not applicable
Author

bommaramcharan,

Thank you for the additional context.  I have read similar set analysis overviews, and they are always insightful.  I like the power of set analysis, though I don't always get it right in practice.  Are you suggesting that I use a specific part of this explaination in my solution?

I tried the test.qvw you attached, however it seems identical to the one uploaded by Arul Settu.  Am I missing something, or did you mean to attach a different qvw file?

PrashantSangle

Hi,

Then also use Date()

Try like,

sum({<Month = {$(=Date(Max(num(Month))))}>} Customers),

1st check in text object

=date(Max(num(Month)))          //Format as per your month date format

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
arulsettu
Master III
Master III

hi i found the solution

Not applicable
Author

Try creating 3 additional columns

Month(Month) as mon,
year(Month) as yr,
num(Month(Month)) as monthnum,

and use the following set analysis

=Sum({$ <yr={$(=max(yr))}, monthnum={$(=max(mon))} > } Customers)

-Qlikuser

Not applicable
Author

It's working!  Thanks for all your help everyone!

I tried all the suggestions you sent in last night, but I couldn't get them to work.  However, it gave me an idea that solved it.

For those who have a similar issue, here's what wound up working:

I added the following line to my load script.

num(year(Month))*100+num(month(Month)) as year_month_num

This gave me a number for each month like 201412, 201501, 201502, etc., with the most recent month having the highest number.

Then in my chart, I used the following expression.

Sum({<year_month_num = {$(=Max(year_month_num))}>} Customers)