Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis only when field has no selection

I've been trying hard to figure this out and it seems simple to me, I'm convinced there's something I'm missing. 

I want to do set analysis on a chart; for example Sum({$ <Year={'2016'}>}TRI) unless there's a selection in the "year" field.  So basically I want the chart to default to the sum of TRI where year is 2016 UNLESS the user has a selection in year.  I've thought of a few workarounds that I don't like, but I'm convinced there must be a way to do exactly what I'm after... Any help is appreciated.

Thanks,

Steve

1 Solution

Accepted Solutions
sunny_talwar

Try this:

=Sum({$<Year = {$(=If(GetSelectedCount(Year) = 0, 2016, Concat(Year, ',')))}>} Sales)

View solution in original post

6 Replies
sunny_talwar

Try this:

=Sum({$<Year = {$(=If(GetSelectedCount(Year) = 0, 2016, Concat(Year, ',')))}>} Sales)

maxgro
MVP
MVP

is 2016 the max Year?

do you always want to display 1 year?

sum({$ <Year={$(=max(Year))}>} TRI)

Not applicable
Author

I'm assuming that you only are looking at yearly aggregations?

If so, this should work.

=Sum({$ <Year = {'$(=Max(Year))'}>}TRI)

It will give you the the sum of whatever year is selected and 2016, the max year, if no selection is made.

kkkumar82
Specialist III
Specialist III

All,

I think Steve wants the default to 2016 and if some thing is selected in  the year then the sum should be calculated on the selections, I would go with Sunny's suggestion but one thing , is 2016 a constant or that is a max among the years.

PrashantSangle

Hi,

or you can try below

if(getselectedCount(Year)=0,sum({<Year={'2016'}>}Sales),Sum(Sales))

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 🙂
Not applicable
Author

Kiran,

Thanks for the reply.  I do want to default to current year, but 2016 is not the max.  There's other data in the dashboard that has dates of 2017, which is the problem I run into when trying to use max(). 

I'll use Sunny's or Max's suggestion, which I had thought of, but was hoping there was a cleaner way of doing it. This way works!  Thanks for everyone's input.