1 Reply Latest reply: Feb 23, 2017 9:28 PM by Vijayanth Radha RSS

    How to sort either ascending or descending based on variable selection using expression

    Vijayanth Radha

      I have a table with dimensions Gender or Age  or Class in column 1 and counts in column 2


      Based on a user set variable (A, B or C), column 1 shall show (gender, age or Class) and Column 2 is a measure called count (ID)


      I'm looking to sorting this table like this:


      If variable is set to A or B, I need it to match my below mention order  in Column 1 (for age and sex),

      If variable is C, the sorting shall be descending of column 2


      The first two line of below expression works fine, but if variable is set to C, the descending of count is not working correctly.


      if (vR = 'A', Match([Age], '0-1 Month', '2 Month-2 Years', '3-11 Years'),

      if (vR = 'B', 'Sex', Match(Sex, 'Male', 'Female', 'Unknown'),

      if (vR = 'C', COUNT(distinct CASE_ID_INT)))