Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Role of Only() here

Hi All,

I want to show data of year 2018 in metric. I have used following expression & it works correctly but could anyone can explain me role of only here. I can understand why only used here. Please explain in details.

Year(Only({<YR={2018}>}[Exp Date]))

Thanks in Adv

8 Replies
Anil_Babu_Samineni

Only Function will get only 2018 Data

Year([Exp Date]) is give all years like your data Assume if you have data 2010 - 2020. It will get 2018 of Exp Dates only

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Not applicable
Author

I have checked articles says if multiple values returns Only() function will return NULL(). But I tried following expression but it works. I don't know exactly how it works.

Year(Only({<YR={2018,2019,2020}>}[Exp Date]))

rahulpawarb
Specialist III
Specialist III

Hello Narendra,

Only() function will fetch a value if there is one and only one possible result from the aggregated data. Example given by you, searching for the only [Exp Date] where the YR = 2018 will return NULL if more than one [Exp Date] has a YR equal to 2018 else [Exp Date].

Hope this will be helpful.

P.S.: Use Only() when you want a NULL result if there are multiple possible values in the sample data.

Regards!

Rahul

Anil_Babu_Samineni

This case, will fetch Dates only for 2018, 2019, 2020

How to use - Only()

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
jonathandienst
Partner - Champion III
Partner - Champion III

Rahul has this exactly correct. The other answers are a little less accurate.

Also see these articles:

Use Aggregation Functions!

It’s all Aggregations

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
muthukumar77
Partner - Creator III
Partner - Creator III

Refer this,

Only - chart function ‒ QlikView

Muthukumar Pandiyan
beck_bakytbek
Master
Master

Hi Narenda,

look at this:

https://community.qlik.com/docs/DOC-8146#comment-58605

i hope that helps

beck

Not applicable
Author

But I tried YR = 2018 which gives 3 lines of output as data contains 3 lines for 2018. It returning 3 lines.