Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Only

Hi Experts,

I have a query regarding only() function. Can we use it in script level or UI level.I have used it in Script level but not getting exact syntax . I have searched in many places but I have not got clarity.

Can you make it out in attached file where I mocked some data in excel and attached. The mocked data might not correct.  Can you make it out .

Thanks a lot.

6 Replies
alexandros17
Partner - Champion III
Partner - Champion III

It works but probably it is not what you want ...

The function Only returns Null if there are more values for the field grouped (month in your case) so it return null because you have more than une distinct value for each month, otherwise only returns the single value.

Hope it helps

Not applicable
Author

Hi, I am not sure what is your requirement. The Only is used in below senerio in the script:

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.

As per your data in Excel, you get the null values in the Sales Per Month.

Not applicable
Author

Hi,

Can you update the excel sheet so that it will give any value from that function. Please send me the updated excel sheet . I just want to understand the usage of only() function.

alexandros17
Partner - Champion III
Partner - Champion III

Here it is

Not applicable
Author

Many thanks for your quick response.

I can use sum(distinct sales) for this requirement also which also give same results. You mean to say only function will be used to get the distinct numeric records from group of records

Which is similar with sum(distinct sales) . Do let me know plz.

alexandros17
Partner - Champion III
Partner - Champion III

... more or less ... I use "Only" when i WANT only a value to be retrieved.