Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional show of chart based on 2 conditions

Hi all,

I am trying to implement a "conditional show" for charts based on two conditions and I want to achieve the following:

If the CurrencyType = 'Reporting Currency' and if Country = Blank, then hide the chart.

I am using the following expression - but it is obviously not the correct one:

if((getfieldselections(CurrencyType='Reporting Currency' and getselectedcount(country)=0),0)

Does anyone know what I is the wrong bit in the expression?

Thanks!

Adi

1 Solution

Accepted Solutions
ToniKautto
Employee
Employee

First of all you have missplaced the expression, it should be added as the Conditional Show and not as Calculation Condition.

Chart Properties > Layout > Show Conditional

A slight correction of my previous suggestion, if you want the user to select a country and a Currency Type except 'Reporting Currency';

SubStringCount( GetFieldSelections([Currency Type], ';'), 'Reporting Currency') = 0 AND GetSelectedCount(Country)>0

If you instead have Country as andatory and Currenc Type as optional;

(GetSelectedCount([Currency Type])=0 OR SubStringCount( GetFieldSelections([Currency Type], ';'), 'Reporting Currency' ) = 0) AND GetSelectedCount(Country)>0

See attached QVW for my example.

View solution in original post

7 Replies
ToniKautto
Employee
Employee

There are a couple things that do not add up properly in your expression.

First of all the Conditional Show expression should be logical, so that it results in True or False. This means that you do not use a IF statement, instead you only use the IF statements condition part as your Conditional Show expression.

As you can see below the GetFieldSelections() inparams in your expression are not valid. The function will return a string, from which you should look for the FieldSelection in.

String GetFieldSelections( fieldname [, valuesep [, maxvalues=6 ]] )

My suggestion is that you first get the currently selected values

GetFieldSelections(CurrencyType, ';')

then you look for your preferred selection within the selected values

SubStringCount( GetFieldSelections(CurrencyType, ';'), 'Reporting Currency' )

By applying this to your requirements you should end up with a expression looking somewhat like;

SubStringCount( GetFieldSelections(CurrencyType, ';'), 'Reporting Currency' ) = 1 AND GetSelectedCount(country)=0

Not applicable
Author

Hi Toni,

thanks for your help on this!

I still have a doubt though as only one part of what I expect is working. 

Using

SubStringCount( GetFieldSelections(CurrencyType, ';'), 'Reporting Currency' ) = 0 AND GetSelectedCount(country)=1

gives me the desired result for all cases, where no country is selected:

1. If Reporting Currency selected, table not shown

2. If Group Currenc selected, table shown.

However when I select a country, the table does not appear at all, independant of the currency selected, but infact, both currency types are valid if looking at one country only....

I was playing around with the expression, but I couln't figure out the proper one.

Thanks again for your help!

ToniKautto
Employee
Employee

Please attach a sample of your QVW file to make evaluation of your problem a bit easier.

If the file contains sensitive data please use the Scrambling function to make it unreadable;

Settings > Document Settings > Scrambling

ToniKautto
Employee
Employee

Ah, now I see that you have written Country = Blank in the initial description. Could you clarify if this means that you have a blank row in your list or if it means that no selections are made in the list?

GetSelectedCount(country)=1 will be true if the case is that you have a selection in your list that corrsponds to blank, meaning that one item actually is selected in the list.

Still it would make it easier to evaluate if you could provide a sample app as I do not really follow in detail on your setup with lists and chart objects.

Not applicable
Author

Hi again,

I am attaching you a file, that helpt to understand the issue.

When I mean country = blank, I am refering to no selection made for country.....

I have a table, where I would like to show some financial indicators per country - as long as all countries are shown (=no country selected), the table only makes sense in Group Currency, not in Reporting (or country specific) currency. But once one country is selected, both Reporting and Group Currency are valid results....

Thanks a lot for your help!

ToniKautto
Employee
Employee

First of all you have missplaced the expression, it should be added as the Conditional Show and not as Calculation Condition.

Chart Properties > Layout > Show Conditional

A slight correction of my previous suggestion, if you want the user to select a country and a Currency Type except 'Reporting Currency';

SubStringCount( GetFieldSelections([Currency Type], ';'), 'Reporting Currency') = 0 AND GetSelectedCount(Country)>0

If you instead have Country as andatory and Currenc Type as optional;

(GetSelectedCount([Currency Type])=0 OR SubStringCount( GetFieldSelections([Currency Type], ';'), 'Reporting Currency' ) = 0) AND GetSelectedCount(Country)>0

See attached QVW for my example.

Not applicable
Author

Toni,

thanks a lot for your help!