Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
d_koti24
Creator II
Creator II

In Which situation we will use only()

Hi all,

In Which situation we will use only(),can any one explain with sample scenario.

regards,

6 Replies
mohammadkhatimi
Partner - Specialist
Partner - Specialist

Hi,

When there is one to one relation ship, we can use only function.

In simple word,

Table:

LOAD * Inline [

Dim1, Dim2, Value

A, India, 10

B, USA, 30

];


If we use Dim1 in textbox without any selection , it display null value for both

=Only(Dim1) or Dim1

If We select any value in Dim1, it display the Value in textbox.

If we need to use "Set Analysis", in that case we can use Only() function.

Only({<Dim2 = {'India'}>}Dim1)  display A.


only(expression )

If expression over a number of records, as defined by a group by clause, contains only one numeric value, that value is returned. Else, NULL is returned.

sunny_talwar

Just created an example for Only() today. Have a look here: Only

awhitfield
Partner - Champion
Partner - Champion

Hi Koti,

Help description of Only:

only([{set_expression}][ distinct ] [ total [<fld {, fld}>]] expression)

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.

Examples:

only( Sales )

only( Price*Quantity )

only( total Salesman )

HTH- Andy

d_koti24
Creator II
Creator II
Author

Still i am in confusion? what is the necessary of use only() in the above example..instead of that if i take dim2 in listbox..then that time also it's working fine..

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Only() - although it appears to be an extremely straightforward function - is actually a very advanced aggregation function that will save your day more than once. If the use of Only() isn't apparent to you yet, don't worry. You do not need it. You have a solution but no corresponding problem, so just ignore it for the time being.

One of my preferred uses for Only() is whenever I need to apply set analysis on very few values to select a single one. Only() is the only function that let's you pick a single value from a range by simply using set analysis.

Peter

maxgro
MVP
MVP

and a detailed explanation

The Only Function

How to use - Only()