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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis help?

Hello Experts,

I am trying to write a simple expression where when a user selects year dimension, it should show the December data, likewise if he selects 3 months (eg: Aug, Sep, Oct), the last month 'Oct' of his selection should show the data.

year and month are my dimensions...

I am trying the below expression... can anyone help with this please....

=if($(vExpressionCond),

  if

   (sum({<month = {'=$max(month)'}>}reportValue)<>0,

  num

   (sum({<month = {'=$max(month)'}>}reportValue),

$(vNumberForm)),''))

Thanks in advance,

Mady

1 Solution

Accepted Solutions
Not applicable
Author

Hello Stefan,

Thats exactly what I was looking for but was confused by looking at the title of the chart columns. Can you help me set up the title for the charts... I mean when I select the date(max(month_num),'MMM') expecting to see the name of the month, it returns Jan instead of Dec... any suggestions please..

Previously I was confused because of the chart Titles... but I am half way through with the issue...

Thanks again for all your time spent.

View solution in original post

16 Replies
swuehl
MVP
MVP

Hi,

I think the dollar sign expansion inside your set expression is not correct,

try

sum({<month = {$(=max(month))}>}reportValue)

Stefan

Not applicable
Author

Stefan, Thanks for the quick response, but its not working. it always shows 0...any other suggestions please?

swuehl
MVP
MVP

Hi,

if it is possible, please post a sample application with your problem.

To pin point your problem, it is best to build it up from bottom to top, i.e. please try the sum expression itself, then add format, then ExpressionConditon.

What kind of data format is month? Have you tried with a literal comparison instead?

Regards,

Stefan

Not applicable
Author

Hello Stefan,

Month is in number format as when i do a max(month) and select year = 2010, it returns 12 (december). And likewise when I select Jan, Feb, March it shows me 3(March) its exactly doing what I want, But how do I use this variable or expression in Set Analysis.

Cannot post an example as my app is big and highly confidential.

Thanks Again,

Mady

swuehl
MVP
MVP

Hi,

so you get a result when using sum(reportValue), right?

Do you get a result for sum({<month={12}>} reportValue) ?

(or any other value?)

month is a dimension, right?

AS I said, please try to use this expression stand alone first, e.g. in text box or chart expression, without further formatting expressions or conditions.

I think the expression I posted is corrected, but try to build a small app myself.

Stefan

swuehl
MVP
MVP

Please find attached my simple example.

Stefan

Not applicable
Author

Ok my month dimension is like jan, feb, mar, apr etc.... but when i do a max(month) in a text box and select  year 2011 it shows the max(month) = 7 and when I select year 2010, itshows the max(month) as 12 which is december... How can I make it work in set analysis??

When I try sum({<month={12}>} reportValue), it wont work...thats the struggle I have..its strange when i select year the max(month) shows the correct number...

Any help or suggestions please?

swuehl
MVP
MVP

How do you generate month? Might be an idea to have a date format instead, or using a numerical monthID linked to the month (name).

Stefan

Not applicable
Author

year and month is generated from a date_value field which is in the format of dd/mm/yyyy 00:00:00 and when I do a max(date_value) select year 2010, it returns 31/12/2010 00:00:00 which is exactly what I want, just that when the end user selects year 2010, it should by default show Dec data....

Thanks Again