8 Replies Latest reply on Feb 11, 2017 5:18 AM by Ramkumar Chandrasekaran

# To sort the view by descending order based on a combination of two fields

Hi,

I have 3 columns in my dataset. Country, VR ID and Net Exposure. The requirement is to display Country, VR ID and the Sum of Net Exposure (sorted by descending order). To achieve this, I have added Country and VR ID to the rows shelf and Sum of Net Exposure to the columns shelf. To sort the sum of net exposure by descending order, I have created a combined field 'Country' and 'VR ID' and hidden this combined field later.

The problem here is, the sorting happens by each country which is not accepted. If I swap the positions of country and VR ID, that is in the order (VRID, Country and Sum of Net Exposure) the sorting happens at VR ID level which is also not right.  This is because the same VR ID might exist in another country as well. How do I sort the view by sum of Net Exposure for the combination of Country and VR ID?

Thanks,

• ###### 1. Re: To sort the view by descending order based on a combination of two fields

I have marked this question as 'Assumed Answered' by mistake. Can you please make it as 'Unanswered'. Apologies for the inconvenience.

• ###### 2. Re: To sort the view by descending order based on a combination of two fields

Hi Ramkumar,

No problem, let's make your question

Which dimensions do you need to be sorted

(by the Sum of Net Exposure in desc order)?

Country only, VIR only or a combination of both?

I assume the latter -- that's why you've created

a Country & VIR (Combined) field, I suppose.

The next logical step is to place the combo pill on Rows.

An alternative to the Combo approach would be

a Table Calculation discrete sorting pill based on

RANK() or INDEX() functions, as shown here:

Fixing "Incorrect" Sorts

Please find the attached (version 9.3) workbook

as an example of both. Hope it helps.

Yours,

Yuri

• ###### 3. Re: To sort the view by descending order based on a combination of two fields

I would like to sort only the sum of Net Exposure by descending order. Apologies that I wasnt clear in my original post.

Attaching a sample twbx file which I just created using RANK(SUM(NET EXPOSURE). I am expecting the result to appear in the below order, which is not coming out as expected in my attachment.

Country    VR

ITA            VR03

FR            VR04

ITA            VR01

GIB            VR02

FR              VR01

• ###### 4. Re: To sort the view by descending order based on a combination of two fields

Like this (in the attached)?

• ###### 5. Re: To sort the view by descending order based on a combination of two fields

Yes.. Awesome. Thank you so much Yuriy.

• ###### 6. Re: To sort the view by descending order based on a combination of two fields

Ramkumar, you're welcome.