Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
demcug82
Contributor III
Contributor III

Wildmatch on combo chart (Filter multiple selection)

Hi All,

I have a Filter (COUNTRY) where i can select USA, Canada, Mexico  e.g.

In an expression of combo chart, if i have selected USA or USA and Canada or USA and Mexico or USA , Mexico and Canada, or anything i have to use Expression A otherwise Expression B using (IF)

I Create this:

if(

wildmatch(concat(COUNTRY,''),'*USA*'),

sum(X),

sum(Y)

)

but works only if I do not select anything (sum X)  or if not select USA (sum Y).


When i select USA use sum Y.


If i insert this expression on a label works perfectly.


I have tried also substringcount(concat(COUNTRY),'USA')=1 but don't works.


Any Idea?

Thanks and Regads,

Demetrio

1 Solution

Accepted Solutions
demcug82
Contributor III
Contributor III
Author

Resolved

I have created a variable: =substringcount(concat(F_ECONOMICS_NAFTA.COUNTRY_FILTER),'USA') and inserted this on expression (>0)

Unless variable the chart don't works fine but with this it's ok!

View solution in original post

12 Replies
sunny_talwar

May be try this

SubStringCount(Concat(DISTINCT COUNTRY), 'USA') >= 1

sunny_talwar

Or this

If(WildMatch(Concat(DISTINCT COUNTRY,''),'*USA*'), Sum(X), Sum(Y))

demcug82
Contributor III
Contributor III
Author

Hi Sunny,

don't works.

The problem it's that in the chart the first condition is false when USA is selected ....in the text object not....and works...

sunny_talwar

Would you be able to share a sample to show the issue?

demcug82
Contributor III
Contributor III
Author

and if use getfieldselection(country) and select only USA works ...

demcug82
Contributor III
Contributor III
Author

Hi Sunny,

in attachment a example.

The goal is that if USA is selected (or anything) we have sum(x) otherywise sum(y).

In example sum(X) 100 for all country

thanks

Demetrio

sunny_talwar

May be this

=If(WildMatch(GetFieldSelections(Country), '*USA*'), Sum({<Country>}X), Sum({<Country>}Y))

When USA is selected

Capture.PNG

When USA is not selected

Capture.PNG

When Multiple things are selected

Capture.PNG

demcug82
Contributor III
Contributor III
Author

Hey Sunny,

don't works yet but i don't wrote all .

In the filter i have others 3 country that have to see only on chart (not selectable on filter) when USA is selected.

For this on the script i have duplicate field country, named country_filter  that write null for this country and used on filter.

That expression used it's :

if(

wildmatch(GetFieldSelections(F_ECONOMICS_NAFTA.COUNTRY),'*USA*'),

// EXPRESSION A 

sum({<F_ECONOMICS_NAFTA.COUNTRY_FILTER=,

F_ECONOMICS_NAFTA.COUNTRY={$(=v_country_exchange_rate_NAFTA2),$(=v_country_exchange_rate_NAFTA)},

F_ECONOMICS_NAFTA.DATA ={">=$(=DATE#((v_selected_period5)&'-01'))<=$(=DATE#((v_selected_period6)&'-01'))"}>}     

F_ECONOMICS_NAFTA.AVERAGE_RATE_FF_MONTHLY),

// EXPRESSION B

sum({<F_ECONOMICS_NAFTA.DATA ={">=$(=DATE#((v_selected_period5)&'-01'))<=$(=DATE#((v_selected_period6)&'-01'))"}>}

F_ECONOMICS_NAFTA.AVERAGE_RATE_FF_MONTHLY)

)

____________

where

v_country_exchange_rate_NAFTA2

=chr(39)&Concat(F_ECONOMICS_NAFTA.COUNTRY_FILTER,chr(39)&','&chr(39))&chr(39)

v_country_exchange_rate_NAFTA  =   'Euro Area','Japan','UK'


______________

This don't works only when USA is select

Where i have to modify it?

sunny_talwar

May be try this

If(WildMatch(GetFieldSelections(F_ECONOMICS_NAFTA.COUNTRY), '*USA*'),

// EXPRESSION A

Sum({<F_ECONOMICS_NAFTA.COUNTRY_FILTER, F_ECONOMICS_NAFTA.COUNTRY =P(F_ECONOMICS_NAFTA.COUNTRY_FILTER) + {$(v_country_exchange_rate_NAFTA)},

F_ECONOMICS_NAFTA.DATA = {">=$(=Date#((v_selected_period5) & '-01'))<=$(=Date#((v_selected_period6) & '-01'))"}>} F_ECONOMICS_NAFTA.AVERAGE_RATE_FF_MONTHLY),

// EXPRESSION B

Sum({<F_ECONOMICS_NAFTA.DATA = {">=$(=Date#((v_selected_period5) & '-01'))<=$(=Date#((v_selected_period6) & '-01'))"}>} F_ECONOMICS_NAFTA.AVERAGE_RATE_FF_MONTHLY))