Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Attend QlikWorld 2020 and hear keynote speaker, Malcolm Gladwell. $300 savings extended to February 9th Learn More
Highlighted
Not applicable

show/hide expressions depending on selection

Hey all,

I am stuck in following thing:

I defined a function to check which values of my fields are selected:

vAllSelectedProject_Check = '=GetFieldSelections(Field_01)';

Then I use this expression in a chart:

if('$(vAllSelectedProject_Check)'='ALL',Sum(expenses/1000),Sum({<Field_01 = {$(vAllSelectedProject_Check)}>}expenses/1000))

So this works awesome, if I select only one value, I see the sum of it. I select 3 values, all of them are accumulated and if I select all values, I get the total sum.

But now I try to add more expressions ... so each expression shoud represent the sum of a value in my field. I am thinking about something like a reference. So for sure I would need to add as many expressions as fields I got. But I can live with that. The most important thing would be that I could show/hide expressions depending on the selections of my field.

Anyone an idea? Would be very happy about any replys!

BR

Henrik

1 Solution

Accepted Solutions
Partner
Partner

Re: show/hide expressions depending on selection

You might want to try separating the conditions and expressions by using the "Conditional" check box in your expression tab and put your condition there. It will perform better and be easier to manage I would think.Capture.PNG

View solution in original post

6 Replies
Partner
Partner

Re: show/hide expressions depending on selection

You might want to try separating the conditions and expressions by using the "Conditional" check box in your expression tab and put your condition there. It will perform better and be easier to manage I would think.Capture.PNG

View solution in original post

Partner
Partner

Re: show/hide expressions depending on selection

You say that this is working??

vAllSelectedProject_Check = '=GetFieldSelections(Field_01)';

Then I use this expression in a chart:

if('$(vAllSelectedProject_Check)'='ALL',Sum(expenses/1000),Sum({<Field_01 = {$(vAllSelectedProject_Check)}>}expenses/1000))

So this works awesome,


But this is only working because of the standard qlikview behavior. You might as well just have Sum(expenses/1000) as your expression. The if condition in your expression is always false, meaning that it will take the second expression

Sum({<Field_01 = {$(vAllSelectedProject_Check)}>}expenses/1000)

As $(vAllSelectedProject_Check) is not correctly formatted for in set analysis, i will ignore that meaning you might as well use

Sum(expenses/1000)


Qlikview will limit these results by selections in Field_01 by default, so what are you are trying to achieve?


Not applicable

Re: show/hide expressions depending on selection

Perfect! That's the reason the thread shows up in "New to QlikView" . Just never used it before, now everything works as expected, thanks a lot!

I use now this:

WildMatch('$(vAllSelectedProject_Check)','*Berlin*') OR '$(vAllSelectedProject_Check)'='ALL'

Partner
Partner

Re: show/hide expressions depending on selection

Glad that helped. Its one of my favorite features they added.

Not applicable

Re: show/hide expressions depending on selection

@Stigchel:

Sum(expenses/1000) wouldn't be enough in my case. The if condition is not always false! If I select all values of my field, the variable vAllSelectedProject_Check turns to "ALL". So it appears quite often ...

Just an example. My field contains the values "Berlin", "Hamburg", "Paris" and "London". If I select "Berlin" and "Hamburg" the variable vAllSelectedProject_Check = "Berlin, Hamburg" ... so I can use this in the set analysis. And if I select ALL fields, so "Berlin", "Hamburg", "Paris" and "London" the vAllSelectedProject_Check = "ALL".

you see I need it

Partner
Partner

Re: show/hide expressions depending on selection

The if condition is only true if all values (and more than 6 (default) possible values exist) and is completely unnecessary as Sum(expenses/1000) will be restricted to the selected values in Field_01 as a default behavior of qlikview. You only need set analysis to either expand or limit the used data set. You don't need it if you just use the current selected data set.