Update: the OP has explained that their problem is that they aren't using SQL at all, this is a DAX problem. So I will update my (already lengthy) instructions for how to do this, with a followup article that deals with the same problem but using DAX instead of SQL to get the required columns to do this work properly.
For anybody who is just casually interested, the short answer resolution is that this is hard to do with a lot of tweaking of specialized design objects in the RDL, and it's not very extensible that way, because you're going to have to hardcode your individual column-tablixes in the designer. BUT it quite easy to do with a dataset that contains proper column and row index values; you only need ONE tablix and you can dynamically set up the number of columns without a bunch of work. Then you group by the row index and the column index, you're done.
So, in the OP's case, the problem is getting those two index values into the dataset. I found this pretty straightforward -- in fact, doing it allowed me to go back and somewhat simplify the required SQL as well -- EXCEPT :
If the report requires a row grouping to be included in the designer object it's more difficult to get the column and row index values to be appropriate to the group level values that you will need. In SQL, this is just a simple case of adding a PARTITION BY instruction, but there are numerous articles on the web about how to do the same thing in DAX, none of which seemed to work for me -- I'm not a DAX expert, so maybe somebody else will chime in with the right way to do that?
So, for DAX, I start with the same basic technique, I will still use one tablix, but I will add some expressions into the row and column groupings to compensate. Still pretty easy and still completely dynamic, and maybe we could do without the exception if a DAX expert wants to think over the problem. What you're looking for is a row and column assignment that looks like this (assuming 2 cols have been requested, group is needed, items are alphabetically sorted, and you need to go Down-Then-Across):
Group |
Item |
Row Index |
Col Index: |
Fruit |
Apple |
1 |
1 |
Fruit |
Peach |
2 |
1 |
Fruit |
Pear |
3 |
1 |
Fruit |
Persimmon |
1 |
2 |
Fruit |
Rasberry |
2 |
2 |
Veg |
Carrot |
4 |
1 |
Veg |
Cauliflower |
5 |
1 |
Veg |
Green Bean |
4 |
2 |
resulting in :
Group |
Col 1 |
Col 2 |
Fruit |
Apple |
Persimmon |
|
Peach |
Rasberry |
|
Pear |
|
Veg |
Carrot |
Green Bean |
|
Cauliflower |
|
Or like this, matching the OP's requirement, Across-Then-Down, again assuming 2 cols and alpha sort:
Group |
Item |
Row Index |
Col Index |
Fruit |
Apple |
1 |
1 |
Fruit |
Peach |
1 |
2 |
Fruit |
Pear |
2 |
1 |
Fruit |
Persimmon |
2 |
2 |
Fruit |
Rasberry |
3 |
1 |
Veg |
Carrot |
4 |
1 |
Veg |
Cauliflower |
4 |
2 |
Veg |
Green Bean |
5 |
1 |
resulting in:
Group |
Col 1 |
Col 2 |
Fruit |
Apple |
Peach |
|
Pear |
Persimmon |
|
Rasberry |
|
Veg |
Carrot |
Cauliflower |
|
Green Bean |
|
Without grouping DAX in either direction will work exactly the same way as the SQL version, and can be swapped as datasets into the same tablix with no other changes, in fact.
The OP also mentioned needing to repeat the headings, which was already anticipated in the original article and continues to work fine.
While this response is lengthy -- in hopes of getting a DAX expert to provide a way that will allow RANKX to give the right grouped index values directly in the dataset -- I'm not being coy by not working out the code details here; that will be longer, deserves to be a blog article.
So here it is: Snaking Columns for I hope the last time ever