Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikviewwizard
Master II
Master II

Only

Hi All,

Please give an example for only(expression ). I did not understand. Thanks in advance.

1 Solution

Accepted Solutions
sunny_talwar

Hopefully this will give some clarity.

Script:

Table:

LOAD * Inline [

Dim1, Dim2, Value

A, India, 10

A, India, 20

B, USA, 30

];

When I create a text box with the expression =Only(Dim2) with no selection, I will see '-' because Dim2 has two values (India and USA).


Capture.PNG

But when I select one of them, I will see that name in there. For example when I select India I will see India in the text box object

Capture.PNG

So, basically when there is only one available value to display, you can use Only() function. Alternatively you can get the same result by just Putting Dim2. But the benefit of using Only() function is that you can use Set analysis with the Only() function.

HTH

Best,

Sunny

View solution in original post

8 Replies
mohammadkhatimi
Partner - Specialist
Partner - Specialist

Hie..

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.

Example 1:

Load Month, only(Price) as OnlyPriceSoldFor from abc.csv group by Month;

Example 2
=wildmatch(capitalize(only({1}Month)),'APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC','JAN','FEB','MAR')


Hope this will helps you to understand only Function



Regards,

Mohammad


sunny_talwar

Hopefully this will give some clarity.

Script:

Table:

LOAD * Inline [

Dim1, Dim2, Value

A, India, 10

A, India, 20

B, USA, 30

];

When I create a text box with the expression =Only(Dim2) with no selection, I will see '-' because Dim2 has two values (India and USA).


Capture.PNG

But when I select one of them, I will see that name in there. For example when I select India I will see India in the text box object

Capture.PNG

So, basically when there is only one available value to display, you can use Only() function. Alternatively you can get the same result by just Putting Dim2. But the benefit of using Only() function is that you can use Set analysis with the Only() function.

HTH

Best,

Sunny

qlikviewwizard
Master II
Master II
Author

Hi mohammadkhatimiti

I did not understand Example 2.

Please apply to second tab of attached application. Thank you.

mohammadkhatimi
Partner - Specialist
Partner - Specialist

If ur charts month(Dimension) is not in sort form at that time we will use this expression....

raju_salmon
Creator II
Creator II

Can you please provide an example for set analysis case?

I think, whenever we get a scenario where we cannot use any aggregate function like sum, count whereas we need to use set analysis... in that case we can use only... am i right?

MayilVahanan

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.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sunny_talwar

Here have a look at the this example:

Capture.PNG

Now you will see that even without making any selection, I am able to see a result. The reason is that within Dim1 = 'A' there is only one value available for Dim2 (India).

HTH

Best,

Sunny

qlikviewwizard
Master II
Master II
Author

Thank you All.