Qlik Community

QlikView Documents

Documents for QlikView related information.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.

How to use - Only()

How to use - Only()

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

Please see below and enjoy responsibly...

Only()

Definition:

If expression or field iterated over the chart dimension(s) contain one single value, that value is returned, else NULL is returned. Only can return numeric values as well as text values.

What does it mean:

When in dimension(column) all values are

the same ,Only will return this value:

                                        (otherwise NULL)

Please load below script and look at our examples:

load * inline

[ Sales,Price,Quantity,Salesman

10,3,10,Robert

10,2,20,Robert

10,3,10,Henric

10,2,20,Oleg

10,4,20,John

10,3,10,Tom

]

After reload our TableBox looks like this:

Now we can create Straight table and used Salesmen as dimension:

1) only(Sales) returns 10 as this is the only single value in this column

2) only(Price*Quantity ) will not return any values for Robert as the the values returned are 60 (2*30) and 30(1*30).

( We will come back to our Salesman later)

Now let's add another dimension -  Price

This time expression will return values for Robert as it will see the combination of dimensions

Robert 2

Robert 3

as one (single) values.

(If you still in doubt go to our script and  change the Price  for Robert in second row to 3)

Let's go back to our example number 3 - only(TOTAL Salesman)

(The Example below is based on help from Henric Cronstrom

as I could not get my head around this expression and where can be used)

When you look at the expression you may wonder why we have TOTAL here.

In most cases you will uses this prefix to get numerical total like:

But TOTAL can also return string value.

If we choose one value from Salesman dimension

only(TOTAL Salesman)  will return this value.

Bonus:

As an aggregation function, only() can be used with set analysis


only({<Price={2}>} Quantity)


is used return Quantity for Salesman where Price is equal to 2.

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

The humble Only() may not be so humble after all.

Not applicable

Robert, All the mysteries about Only() has been cleared. Thank you very much

Another clear explanation, thanks Robert.

One further point on Only is that if a field is used without an aggregation expression,

then the Only() function is implied.

This is explained by Henric hic‌ in his blog It’s all Aggregations

    =OrderID

A single field reference is not an aggregation, so this is an ill-formed expression. But QlikView will not throw an error. Instead it will use the Only() function to interpret the field reference. I.e., if there is only one value, this value will be used. But if there are several possible values, NULL will be used. So, it depends on the circumstances whether an expression without aggregation function is correct or not.

daniel_kusiak
Contributor II

Excellent guides Robert and we're still feeling hungry 

Not applicable

Can only set analysis be used in dimesions?

Could you specify our question?

Not applicable

Just wanted to ask, if we can use 'Set analysis using Only' in the Dimensions.. I was getting error in Calculation,  while trying to do it.

Yes we can use in Set Analysis.

You can  post your error here or better create new topic in the right part of the forum

Not applicable

ok.. thanks

Version history
Revision #:
1 of 1
Last update:
‎03-19-2015 01:53 AM
Updated by: