Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selecting single MonthYear expression not working

Hey guys,

What I'm trying to do seems like it should work, but doesn't seem to be.

I'm trying to set up my line chart so that when only a single month is selected, the chart isn't filtered at all.

ie. Min(MonthYear) = Max(MonthYear)

So if I select Oct-14 in the chart, Oct-14 is both the min and the max MonthYear value.

But if I select a range of months, Oct-14 to Dec-14, the min and max MonthYear value are different.

So what I've done is make a simple if statement.

If(min(MonthYear) = max(MonthYear), Sum({$<MonthYear=>}Price), Sum(Price))

But it doesn't seem to be working. Instead of Sum({$<MonthYear=>}Price) being executed when a single MonthYear is selected, Sum(Price) is. But seems to be working fine when more than one MonthYear is selected.

My MonthYear is in the load statement as so:

Date(monthstart(TempDate), 'MMM-YY') AS MonthYear

Thanks in advance!

1 Solution

Accepted Solutions
Not applicable
Author

I worked it out!

If(GetSelectedCount(MonthYear) = 1, Sum({$<MonthYear=>}Price), Sum(Price))

Thanks to this thread.

Thanks for the help anyway Michael!

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Works for me...

Can you test something simpler than that, e.g.

If(min(MonthYear) = max(MonthYear), 1,0)

Not applicable
Author

In a text and image chart it works fine, but in a bar chart it doesn't.

If I select more than 1 month in my bar chart, each month will show 1, but in my text and image chart it will show 0.

Here's a screen to show you what I mean. The same expression you posted is used in both the bar chart and text and image chart (the other two are min(MonthYear) and max(MonthYear)).

qlik2.PNG

qlik1.PNG

On the second image in the bar chart, all months should equal 0, right?

Not applicable
Author

Hi james,

From my understandings, we can use Get selected count function.

Please check attached .qvw.

Hope it helps you

BR

Susvith

Not applicable
Author

I worked it out!

If(GetSelectedCount(MonthYear) = 1, Sum({$<MonthYear=>}Price), Sum(Price))

Thanks to this thread.

Thanks for the help anyway Michael!

Not applicable
Author

Hi Susvith, I just worked it out just before you posted, but thanks anyway!

Not applicable
Author

NP

I am glad you got it.

BR

Susvith