SSRS: How to Display Multiple Columns (Header and Value) Horizontally Stacked in one Row Cell
Introduction
This article is the outcome of an answer to this question in the MSDN SSRS forum.
Solution
Example :
Consider below query is my dataset :
DECLARE @sample_data table
(
Name varchar(50),
AgeYears INT,
WeightPounds INT,
HeightInches INT
)
insert @sample_data SELECT 'Anna',84,90,60
insert @sample_data SELECT 'sarah',38,120,67
SELECT * FROM @sample_data
If we need columns AgeYears
,WeightPounds
,HeightInches horizontally stacked in one row cell:
Add a Matrix, under Rows add Name field and then Insert Row -> Inside Group - Below as shown in below image. Similarly add two more rows.
Under Columns -> Data : below is the expressions for three inserted rows:
="Age"+Space(3)+CStr(Fields!AgeYears.Value)
="Weight"+Space(3)+Cstr(Fields!WeightPounds.Value)
="Height"+Space(3)+Cstr(Fields!HeightInches.Value)
After formatting and alignment, if we click on Preview tab we can notice the expected report as shown in below image:
If we don't need lines in between Age, Weight & Height then add Tablix with two columns Name and Stats.
With Name value=Fields!Name.Value
& Stats Value ="Age " + Cstr(Fields!AgeYears.Value) + VBCRLF + "Weight " + Cstr(Fields!WeightPounds.Value) + VBCRLF
- "Height " + Cstr(Fields!HeightInches.Value)
After formatting and alignment, if we click on Preview tab we can notice the expected report as shown in below image: