Skip to main content
Announcements
Talend Data Catalog 8.0 End of Support: December 31, 2024 Get Details

Missing Manual - GetFieldSelections() + Bonus Example

cancel
Showing results for 
Search instead for 
Did you mean: 
robert_mika
Master III
Master III

Missing Manual - GetFieldSelections() + Bonus Example

Last Update:

Mar 2, 2015 9:55:50 AM

Updated By:

robert_mika

Created date:

Mar 2, 2015 9:55:50 AM

Attachments

Have you ever wondered how the examples from the Qlikview help may look like?

Please see below and enjoy responsibly...

GetFieldSelections()

Definition:

Returns a string with the current selections in a field.

valueSep - is the separator to be put between field values. The default is ', '.

max_values  - is the maximum number of field values to be individually listed.

                      When a larger number of values is selected the format 'x of y values' will be used instead.

                      The default is 6.

Preparation:


Script to play with:

Load * Inline

[

Year

2007

2008

2009

2010

2011

2012

2012

2013

2014

2015

2016

]

Example 1:

GetFieldSelections(Year )


Our field Year has 10 values (Years from 2007 to 2016)

The default separator is ',' (coma)

The maximum default numbers of values is 6

We used the same expression for all 3 sets of data

Left: Selection of 6 values

Middle: When more that 6 values the result will change to show the values which are not selected.

Right: Selecting whole sets of values will return 'ALL' as result

DataExpression and Results

Example 2: valueSep


We can assign here any character (or string).



Examples 3: max_values

The default values of 6 is overwritten by the value we have specified(10)

Interesting:

When playing with this function somehow I managed to get result like below

If you can replicate it please post it.

Bonus:

Practical use:

PROBLEM OF DIFFERENCE OF SUM

Still feeling hungry?

How to use - Only()

Do you Qualify?- How to use QUALIFY statement

How to use - Dimensionality()

Missing Manual - GetFieldSelections() + Bonus Example

MaxString & MinString - How to + examples

The second dimension... or how to use secondarydimensionality()

How to use - MissingCount()

How to use- Dual()

Expression Scene Investigation, E1: Moving Average

Comments
Not applicable

Hello Robert,

Really interesting post!!

I tried to achieve below scenario & found the following thing:


The above result is possible when your default 'max_values' parameter has value less than your selected number of values.

Regards

Kiran

robert_mika
Master III
Master III

Thanks for sharing Kiran.

This was my initial thought but I was not able to replicate this result.

isorinrusu
Partner - Creator III
Partner - Creator III

Thanks for sharing!

It seems like from SR9 (at least) there is a new field: state_name. According to the documentation, an Alternate State must be specified, and therefore it returns the field selections applied to that Alternate State.

getfieldselections.png

Regards,

Sorin.

robert_mika
Master III
Master III

Thank you Sorin for updated.

I have created this document on SR2.

It looks like something has been changed.

This tell me to include version number with each document.

Not applicable

Robert, I used the following =GetFieldSelections([FieldName], '~', 1) and it returns 1 selection, 1 NOT selected, ALL or # of #.

SR5 where Alternate State is a drop-down option in Text Box rather than built into the function.

P.S. Would more control be possible if GetSelectedCount and GetAlternativeCount were used?

datanibbler
Champion
Champion

Using GetselectedCount() and GetAlternativeCount(), you could build a string like >> selected 6 of 10 << or >> selected: all but 4 << or whatever - or you could fix the below dilemma by hard-coding the treshold.

I don't quite understand - I have experimented a bit with different max_value parameters (I had this exact list of 10 years for an example) and I don't quite understand when exactly the output switches from "4 of 10" or "5 of 10" to "NOT ..."

=> Both happen when there are more selected values than the max_value_parameter, but I don't see the pattern ...

=> Can anyone explain the logic behind this?

Thanks a lot!

Not applicable

Hi DataNibbler,

To be precise about your query, it all depends on value pass in the parameter 'max_value' & number of selection/s made in the field.

If you suppose let set this threshold to 4 for e.g.. then for your any 4 selections, you will get output as selected values. henceforth, you find output as '# of #" in case of more values selected.After that as soon as count of unselected value equal to or less than threshold value (4 in this case) you will get output in the format 'NOT...'

This is what I understood when testing on the different scenario.

Kindly share,if any one find more details on this.

Regards

Kiran

Colin-Albert

Another good post Robert.

These are worthwhile as many of the examples in the help file are very sparse.

robert_mika
Master III
Master III

Thank you Colin.

Appreciate your comment.

Not applicable

Thanks for the clear explanation!

Does anyone know if it's possible to avoid getting output in the format 'NOT...'?

Version history
Last update:
‎2015-03-02 09:55 AM
Updated by: