Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
aprem
Contributor
Contributor

GroupBy 2 columns and find the 2nd, 3rd highest sum

I have finance data such that there are 3 columns: physician_name who is receiving payment, sender_name who is sending money to the physician, and the corresponding amount.

This data is at a transaction level, where each row represents one transaction.

I want to GroupBy phy_name and sender_name and display the amount that the 2nd highest sender is paying to the physician. When I say 2nd highest sender, I mean at a physician level, that is the 2nd highest sender can be different for different physicians. So simply GroupBy and take the 2nd highest sender amount at the physician level. Qlik Sense Table.

Labels (2)
4 Replies
PrashantSangle

for Group By, you can create Key by combining those 2 field in one "phy_name"&'_'& "sender_name"

and for 2nd highest sender you can use max(fieldName,2)

or set analysis

Only(Aggr(max(FieldName,2),phy_name,sender_name))

 

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
aprem
Contributor
Contributor
Author

Does it also take into account, the sum? Because the sender can send multiple payments to the same physician.

aprem
Contributor
Contributor
Author

Also I tried this statement in my table, it gives no output.

 

Again my data in the backend is at each transaction level, but my qlik sense table is at physician name level.

So if one column is phy_name as dimension, another column is the top paying company amount and expression is : "max(aggr(sum(total_amount_of_payment_usdollars_op),sender_organization_op, phy_name))"

 

Similarly I would like to print the 2nd highest payer/sender.

Sivapriya_d
Creator
Creator

Hi,

check if this helps.

Sivapriya_d_1-1699115300753.png

 

update below expression with your fields and add as dimension for payer/sender. Uncheck include null values for the dimension
 =IF(AGGR(Rank(SUM([gross income])),City,[Product line])=2 or
AGGR(Rank(SUM([gross income])),City,[Product line])=3,[Product line])

 

you can refer this link : https://community.qlik.com/t5/New-to-Qlik-Sense/How-to-get-second-Highest-Rank-for-each-ID-in-table/...

Thanks,