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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
dandaanilreddy
Partner - Creator III
Partner - Creator III

Top 3 values not working

Hi

I'm trying to get the top 3 values without doing aggregation in the expression. My top 3 deals value should be based on base_value. In script i have created the sorting order by desc based on base value. This logic was working fine when i don't have same values but not working when i have same values. Below is issue i'm facing with the logic when i use only in expression as i should not apply aggregation in the expression.  Below is the sample data. Please can someone let me know how to achieve the expected output.

Expression for base value: only({<company={'ABC'},sort={"<4"}>}base_value) 

The above expression repeats for the other measures.

 

Month date base_value product name value 1 value 2 value 3
Aug 2018-08-02 40 samsung 10 0.0008 6
Aug 2018-08-13 30 Nokia 8 0.0006 5
Aug 2018-08-10 20 apple 5 -0.0005 4
Aug 2018-08-10 20 apple 5 0.0001 4
             
Qlik Output             
Aug 2018-08-02 40 samsung 10 0.0008 6
Aug 2018-08-13 30 Nokia 8 0.0006 5
Aug 2018-08-10 20 apple 5 - -
             
Expected output            
Aug 2018-08-02 40 samsung 10 0.0008 6
Aug 2018-08-13 30 Nokia 8 0.0006 5
Aug 2018-08-10 20 apple 5 0.0001 4
Labels (1)
1 Reply
Vegar
MVP
MVP

Depending if your other fields contain information that can help you prioritise the 4th row over the 3rd, then you could consider replacing only() with FirstSortedValue().