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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis syntax problem

I've got a syntax problem with set analysis in an expression:

In a chart I have the following fields:

  • Customer
  • Startdate (Startdate is the date the customer buys his products exclusively at my company.. before this date he was already a customer)

I want to compare the sales of the year before and after the customer started to buy exclusively at my store (when he buys exclusively he gets discount).

For the expression I can use the field

  • MinOneYearStartdate

This field contains the year before the startdate.... (for example: if Startdate = 1-1-2008 MinOneYearStartdate is 2007)

In the chart I use the following expression:

=Sum( {<Year={$(#=Only(MinOneYearStartdate))} >} Sales)

Somehow this does only work when I select one customer... When I have more customers selected it doesn't anymore... When I use:

=Sum( {<Year={$(#=Only(Year-1))} >} Sales)

The set analysis expression is working with multiple customers selected but I want the MinOneYearStartdate as value there of course.... can someone help me out? Thanks!

1 Solution

Accepted Solutions
Not applicable
Author

Hello, the problem is that your field MinOneYearStartdate is calculated I'm guessing for every customer, so when you apply the function only it will return null when more than one customer is selected, that's the reason of the behaviour you just explained. I think you can solve this problem by using a sum(if) instead of the set analysis.

Regards

View solution in original post

4 Replies
Not applicable
Author

Hello, the problem is that your field MinOneYearStartdate is calculated I'm guessing for every customer, so when you apply the function only it will return null when more than one customer is selected, that's the reason of the behaviour you just explained. I think you can solve this problem by using a sum(if) instead of the set analysis.

Regards

Not applicable
Author

have similar problem

Assume variable "gender" with values "men" and "women"

Assume variable "age" associated with each record. Values can be "young" or "old"

In one bar chart with 4 bars, I want to compare count on "young men" with count on "all men" and count on "young women" with count on "all women"

I think the string ($<age>=) goes in there somewhere, but I can make this work.

Not applicable
Author

Hey Bill, in your case that can be solved with set analysis your expression should look similar to this:

count({gender = {'men'}, age = {'young'}} PersonID)

You can modify the above to get your 4 expressions.

Regards

Not applicable
Author

Thanks.. going to try with an if statement!