Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mhassinger
Creator
Creator

Dynamically switching which field is being used in a filter

Wondering if this is possible.

I've got a little data island with two values - Monthly and Weekly, and two fields in the fact table called Month-Year and Week-Year.

Depending on what the user selects (Monthly or Weekly), I'd like a filter on the page to switch between displaying values for the Month-Year field or the Week-Year field.

I've tried creating a variable that returns the string 'Month-Year' and 'Week-Year' and using that variable in the filter's dimension definition, but that doesn't work. Any ideas?

Labels (1)
6 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

It should work if you wrap your Dim field reference in a $() like

=$(=MinString(Dim))

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

Vegar
MVP
MVP

To do Rob's solution I think you need to rename or associate your 'Monthly' and 'Weekly' values to 'Month-Year' and  'Week-Year' .

Let's say you have this:

GUI:

LOAD * INLINE [

Period, Dim

Monthly, Month-Year

Weekly,Week-Year];

 

ApplicationData:

Load * From TransaktionData;

];

 

Then you should be able to use Rob's suggested technique. Making selections in [Period] and displaying the field name found in the associated [Dim] field. 

=[$(=MinString(Dim))]

mhassinger
Creator
Creator
Author

Thank you both for the input. I must still be missing something because it doesn't work.

Here's my inline table load for the data island.

TimeSelect:
Load * Inline
[
Monthly or Weekly, Dim
Monthly, Month-Year
Weekly, Week-Year
];

Here is my variable definition for vTimeFrame.

if(Only([Monthly or Weekly]) = 'Monthly', 'Month-Year','Week-Year')

That seems to work fine because $(vTimeFrame) in a text & Image object evaluates it correctly to one of the two strings.

Finally in my filter pane dimension field expression I have what Rob proposed:

=$(=MinString(vTimeFrame))

I must just be misunderstanding something.


Vegar
MVP
MVP

Try using  this as a dimension.

[$(vTimeFrame)]

 

 

mhassinger
Creator
Creator
Author

No go. It actually gives me a invalid dimension error when I do that. With '=$(=MinString(vTimeFrame))' the filter pane was empty but it didn't give an error.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

A couple of thoughts. Since you have already created the string in the variable, you wouldn't use MinString.  But you don't really need the variable at all. Just go with using the Dim field. 

=$(=MaxString(Dim))