Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
qlikviewwizard
Honored Contributor II

Only

Hi All,

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

1 Solution

Accepted Solutions
Highlighted

Re: Only

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
Highlighted
Partner
Partner

Re: Only

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


Highlighted

Re: Only

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

Highlighted
qlikviewwizard
Honored Contributor II

Re: Only

Hi mohammadkhatimiti

I did not understand Example 2.

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

Highlighted
Partner
Partner

Re: Only

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

Highlighted
raju_salmon
Contributor II

Re: Only

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?

Highlighted

Re: Only

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.

Highlighted

Re: Only

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

Highlighted
qlikviewwizard
Honored Contributor II

Re: Only

Thank you All.