Expression in RDLC row group to sort on other field

Hugh Self Taught 106 Reputation points
2025-06-09T15:07:44.3766667+00:00

Hi Gurus, I have a rdlc report that has a group on one of the fields. I pass a parameter to the report which is used to specify sorting on another field but keeping the current grouping. Under Group Properties> Sorting I entered the following expression but I can't figure out how to have a secondary sort on another field at the same time.

=switch(Parameters!SortVal.Value = 3,Fields!CoupleNumber.Value,Parameters!SortVal.Value = 2,Fields!M_Fname.Value,Parameters!SortVal.Value = 4,Fields!M_Sname.Value,Parameters!SortVal.Value = 1,Fields!F_Fname.Value,Parameters!SortVal.Value = 5,Fields!F_Sname.Value)

I can't find any reference anywhere that'll allow me to do that. For example I'd like to have

Parameters!SortVal.Value = 2,Fields!M_Fname.Value and Fields!F_Fname.Value. Is this possible?

Developer technologies | VB
{count} votes

1 answer

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 3,725 Reputation points Microsoft External Staff
    2025-11-14T14:48:17.2066667+00:00

    Thank you for reaching out.

    Your observation is correct: concatenating M_Fname and F_Fname only creates a single composite key, so the report sorts them as one combined string. That’s why it doesn’t behave like a true “primary then secondary” sort.

    The proper way in RDLC is to use multiple sort entries in the group’s Sorting settings. Keep your parameter-driven expression as the first sort (primary), then add another entry for the secondary field. This ensures the engine applies them in sequence first by the chosen field, then by the tiebreaker while preserving the current grouping. You can even add a third key (like an ID) for stability if needed.

    Concatenation is a partial workaround, but multiple sort rows are the intended solution for predictable multi-level sorting.

    Please let us know if you require any further assistance, we’re happy to help.

    If you found this information useful, kindly mark this as "Accept Answer".


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.