Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Dayna
Creator II
Creator II

Show the Top 3 concatenated in a table

Hi All,

I have a table with a variety of fields and I want to combine the top 3 reasons on it.

At the moment, my table data looks like this:

NameQuantitySpeedResult
test1100202000
test23456666
test3123445

I then have codes against these names with a duration - at the moment, the duration is calculated by some set analysis, which hopefully won't confuse matters! i.e.

NameCodeDuration
test1code110
test1code220
test1code350
test1code440
test1code55
test1code6100

What I want as an end result, is to rank these values and add it to my original table, i.e.

NameQuantitySpeedResultTop 3
test1100202000code 6 (100), code3 (50), code4 (40)
test23456666
test3123445

I haven't quite worked out how to add the rank concatenated, let alone the 'nice' value rather than the ranked value.

Hopefully the above makes sense, and you can help me with my query.

Many thanks in advance,

Dayna

1 Solution

Accepted Solutions
sunny_talwar

Try this

=Concat(DISTINCT Aggr(If(Rank(Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>} event.downtime_hour_duration)) < 4, Reason.EnglishDescription2 & '(' & Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>} event.downtime_hour_duration) & ')'), rawdata.leg, Reason.EnglishDescription2), ', ', -Aggr(Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>} event.downtime_hour_duration), rawdata.leg, Reason.EnglishDescription2))

View solution in original post

4 Replies
sunny_talwar

Try this

=Concat(DISTINCT Aggr(If(Rank(Duration) < 4, Code & '(' & Duration & ')'), Name, Code), ', ', -Duration)


Capture.PNG

Dayna
Creator II
Creator II
Author

Thanks for the quick response Sunny! Somewhere, there's an error in my formula, this is what I'll end up with:

=Concat(DISTINCT Aggr(If(Rank(

Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>}event.downtime_hour_duration)

) < 4, Reason.EnglishDescription2 &

'(' & Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>}event.downtime_hour_duration) & ')'), rawdata.leg, Reason.EnglishDescription2), ', ', -Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>}event.downtime_hour_duration))

sunny_talwar

Try this

=Concat(DISTINCT Aggr(If(Rank(Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>} event.downtime_hour_duration)) < 4, Reason.EnglishDescription2 & '(' & Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>} event.downtime_hour_duration) & ')'), rawdata.leg, Reason.EnglishDescription2), ', ', -Aggr(Sum({<event.value={'STOP'}, line.devicetype= {'WRAPPER'}>} event.downtime_hour_duration), rawdata.leg, Reason.EnglishDescription2))

Dayna
Creator II
Creator II
Author

Sunny, you're amazing! Thank you!