Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

truppell
Contributor

Show different fields based on a selection?

Hi,

I have data that looks something like this:

LocationWeekday visitorsWeekend visitorsWeekday salesWeekend Sales
A1234620
B1621103
C1532315
D1745825

I would like to be able to have a single chart table that shows all the locations, but displays either the Weekday stats or the weekend stats based based on a user selection.

So it would be something like this:

Weekday Stats

Weekend Stats

(some way for a user to select between the two)

LocationVisitorsSales
A126
B1610
C153
D178

Is this possible? Perhaps I need to do something when I load the data?

Thanks.

9 Replies
MVP
MVP

Re: Show different fields based on a selection?

Hi Tanya,

yes, you can do it if you load an extra field "Measure" with the possible values like "Weekday Stats" and "Weekend Stats", and let users select the value from a Filter.

In the chart, have a conditional expression that shows one formula or another, based on the selected value.

cheers,

Oleg Troyansky

Check out my new book QlikView Your Business - The Expert Guide for QlikView and Qlik Sense

MVP
MVP

Re: Show different fields based on a selection?

Check the attached

Script:

Table:

LOAD Location,

     [Weekday visitors],

     [Weekend visitors],

     [Weekday sales],

     [Weekend Sales]

FROM

[https://community.qlik.com/thread/214279]

(html, codepage is 1252, embedded labels, table is @1);

Selection:

LOAD * Inline "

Field, Visitor, Sales

WeekDay, Sum([Weekday visitors]), Sum([Weekday sales])

WeekEnd, Sum([Weekend visitors]), Sum([Weekend Sales])

";

Straight Table

Dimension

Location

Expressions

1) =$(=Visitor)

2) =$(=Sales)


Capture.PNG

MVP
MVP

Re: Show different fields based on a selection?

Maybe like

LOAD

     Location,

     "Weekday visitors" as Visitors,

     "Weekday sales" as Sales,

     'Weekday stats' as type

FROM YourTableSource;

Concatenate

LOAD

     Location,

     "Weekend visitors" as Visitors,

     "Weekend sales" as Sales,

      'Weekend stats' as type

FROM YourTableSource;

MVP
MVP

Re: Show different fields based on a selection?

Well, just saw that it is Qlik Sense. Not sure if this will work in Sense or not

UPDATE: Seemed to have worked (with the only problem that we don't have the option to make the filter box have 'Always One Selected Value'). This might become an issue when user selects both weekday and weekend in the field filter.

But check it out

truppell
Contributor

Re: Show different fields based on a selection?

Thanks Sunny. This answered my question (except for the single selection part).

MVP
MVP

Re: Show different fields based on a selection?

What is the single selection part?

truppell
Contributor

Re: Show different fields based on a selection?

What you mentioned above - that it fails if the user selects multiple filter entries. I need some way to restrict this to a single selection.

MVP
MVP

Re: Show different fields based on a selection?

May be reddys310‌ can help here

reddys310
Honored Contributor II

Re: Show different fields based on a selection?

Hi Tanya,

Qlik by default allows multiple selection.If you have to restrict to have a single selection, then it would be better if you have toggle buttons which is an extension. Check Qlik branch if you can find an extension for this.