Thursday, April 8, 2010

Sorting Asc / Desc on Same Column

Reqmt: Create a report displaying Product and Sales and Sort Product Asc or Desc depending on user selection.

Solution:

Step 1: Create a Prompt Page to accept user selection for Asc / Desc. Lets call this prompt as SortSel and have use value for static choices set as 1 for Asc and 2 for Desc.

Step 2: Create report page that includes Product and Sales Data Item.

Step 3: Create 2 data items called as SortAsc, SortDesc.

SortAsc - Case when ?SortSel? = 1 then Product else '1' end
SortDesc - Case when ?SortSel? = 2 then Product else '1' end

Step 4: In Advance Sorting for the list Include SortAsc and set sort on this to Asc. Then include SortDesc and set Sort on this to Desc.

When User selects 1, the SortAsc data item is populated with Product and SortDesc is populated with 1 and hence Sorting Asc on SortASc produces the desired result and a sort desc on SortDesc has no impact.

When User selects 2, the SortAsc data item is populated with 1 and SortDesc is populated with Product and hence Sorting Desc on SortDesc produces the desired result and a sort asc on SortAsc has no impact.

2 comments:

Anonymous said...

Thanks for providing the solution.

Anonymous said...

Dear Mr/Mrs,

Thanks a lot for posting this method! I've been looking so long for this and thanks to you I have found a "simple" solution!

So THANKS a lot!

Regards