SSRS Report from a PIVOT query with unknown number of columns
up vote
0
down vote
favorite
I have a PIVOT query that is returning an unknown number of dynamic columns. So the query will return something like
ID | Col1 | Col2 | ..... | ColN
ID is the only static column and the rest are all dynamic. The number and the names of the columns are unknown.
How can I write a report in SSRS that can handle this? Any tips and direction will be appreciated.
Thanks.
sql tsql reporting-services pivot
add a comment |
up vote
0
down vote
favorite
I have a PIVOT query that is returning an unknown number of dynamic columns. So the query will return something like
ID | Col1 | Col2 | ..... | ColN
ID is the only static column and the rest are all dynamic. The number and the names of the columns are unknown.
How can I write a report in SSRS that can handle this? Any tips and direction will be appreciated.
Thanks.
sql tsql reporting-services pivot
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a PIVOT query that is returning an unknown number of dynamic columns. So the query will return something like
ID | Col1 | Col2 | ..... | ColN
ID is the only static column and the rest are all dynamic. The number and the names of the columns are unknown.
How can I write a report in SSRS that can handle this? Any tips and direction will be appreciated.
Thanks.
sql tsql reporting-services pivot
I have a PIVOT query that is returning an unknown number of dynamic columns. So the query will return something like
ID | Col1 | Col2 | ..... | ColN
ID is the only static column and the rest are all dynamic. The number and the names of the columns are unknown.
How can I write a report in SSRS that can handle this? Any tips and direction will be appreciated.
Thanks.
sql tsql reporting-services pivot
sql tsql reporting-services pivot
asked 14 hours ago
JackSmith
114
114
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
SSRS will not be able to handle your pivot table because the columns are not known at design time. SSRS has feature called Matrix
that will handle the pivot a run time based off run time data if your design time structure is static.
ID | ColumnName | Value
------------------------
1 | Colu1 | Value1
1 | Colu2 | Value2
2 | Colu2 | Value2
I would recommend that you return detail rows from TSQL and allow SSRS to handle the pivot. This will allow for one stored procedure to be used for multiple SSRS reports and aggregations instead of the single aggregation provide by PIVOT
.
To save on duplicate processing, Matrix
will also handle the sorting so no need to sort inside of TSQL.
Reference: Create a Matrix
So currently my query returns data in the form I listed above. You want me to write a query in the format - ID | Column | Value and then use a matrix in SSRS?
– JackSmith
14 hours ago
SSRS does a wonderful job at runtime pivot tables. Yes, I would write the query with the above structure and use a matrix.
– rschoenbach
14 hours ago
Ok I wrote the query to get the data in the following format. However I need one little change. The query is select distinct pApps.ApplicationID, ppl.LastName As ColName, isnull(ev.AnswerNumeric, 0) as ColValue from pApps inner join ev on pApps.SomeColumn = ev.SomeColumn inner join ppl on pApps.SomeColumn = ppl.SomeColumn Order By ApplicationID I need to add a total column as well. The data is coming out as ApplicationID | ColName | ColValue 12 | A | 5 12| B | 9 14 | A | 12 14 | B | 3 I need to add a total for each application that is the sum of A & B
– JackSmith
13 hours ago
@JackSmith SSRSMatrix
has the ability to create a total row for you. Reference
– rschoenbach
13 hours ago
Ok great thanks
– JackSmith
13 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
SSRS will not be able to handle your pivot table because the columns are not known at design time. SSRS has feature called Matrix
that will handle the pivot a run time based off run time data if your design time structure is static.
ID | ColumnName | Value
------------------------
1 | Colu1 | Value1
1 | Colu2 | Value2
2 | Colu2 | Value2
I would recommend that you return detail rows from TSQL and allow SSRS to handle the pivot. This will allow for one stored procedure to be used for multiple SSRS reports and aggregations instead of the single aggregation provide by PIVOT
.
To save on duplicate processing, Matrix
will also handle the sorting so no need to sort inside of TSQL.
Reference: Create a Matrix
So currently my query returns data in the form I listed above. You want me to write a query in the format - ID | Column | Value and then use a matrix in SSRS?
– JackSmith
14 hours ago
SSRS does a wonderful job at runtime pivot tables. Yes, I would write the query with the above structure and use a matrix.
– rschoenbach
14 hours ago
Ok I wrote the query to get the data in the following format. However I need one little change. The query is select distinct pApps.ApplicationID, ppl.LastName As ColName, isnull(ev.AnswerNumeric, 0) as ColValue from pApps inner join ev on pApps.SomeColumn = ev.SomeColumn inner join ppl on pApps.SomeColumn = ppl.SomeColumn Order By ApplicationID I need to add a total column as well. The data is coming out as ApplicationID | ColName | ColValue 12 | A | 5 12| B | 9 14 | A | 12 14 | B | 3 I need to add a total for each application that is the sum of A & B
– JackSmith
13 hours ago
@JackSmith SSRSMatrix
has the ability to create a total row for you. Reference
– rschoenbach
13 hours ago
Ok great thanks
– JackSmith
13 hours ago
add a comment |
up vote
0
down vote
accepted
SSRS will not be able to handle your pivot table because the columns are not known at design time. SSRS has feature called Matrix
that will handle the pivot a run time based off run time data if your design time structure is static.
ID | ColumnName | Value
------------------------
1 | Colu1 | Value1
1 | Colu2 | Value2
2 | Colu2 | Value2
I would recommend that you return detail rows from TSQL and allow SSRS to handle the pivot. This will allow for one stored procedure to be used for multiple SSRS reports and aggregations instead of the single aggregation provide by PIVOT
.
To save on duplicate processing, Matrix
will also handle the sorting so no need to sort inside of TSQL.
Reference: Create a Matrix
So currently my query returns data in the form I listed above. You want me to write a query in the format - ID | Column | Value and then use a matrix in SSRS?
– JackSmith
14 hours ago
SSRS does a wonderful job at runtime pivot tables. Yes, I would write the query with the above structure and use a matrix.
– rschoenbach
14 hours ago
Ok I wrote the query to get the data in the following format. However I need one little change. The query is select distinct pApps.ApplicationID, ppl.LastName As ColName, isnull(ev.AnswerNumeric, 0) as ColValue from pApps inner join ev on pApps.SomeColumn = ev.SomeColumn inner join ppl on pApps.SomeColumn = ppl.SomeColumn Order By ApplicationID I need to add a total column as well. The data is coming out as ApplicationID | ColName | ColValue 12 | A | 5 12| B | 9 14 | A | 12 14 | B | 3 I need to add a total for each application that is the sum of A & B
– JackSmith
13 hours ago
@JackSmith SSRSMatrix
has the ability to create a total row for you. Reference
– rschoenbach
13 hours ago
Ok great thanks
– JackSmith
13 hours ago
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
SSRS will not be able to handle your pivot table because the columns are not known at design time. SSRS has feature called Matrix
that will handle the pivot a run time based off run time data if your design time structure is static.
ID | ColumnName | Value
------------------------
1 | Colu1 | Value1
1 | Colu2 | Value2
2 | Colu2 | Value2
I would recommend that you return detail rows from TSQL and allow SSRS to handle the pivot. This will allow for one stored procedure to be used for multiple SSRS reports and aggregations instead of the single aggregation provide by PIVOT
.
To save on duplicate processing, Matrix
will also handle the sorting so no need to sort inside of TSQL.
Reference: Create a Matrix
SSRS will not be able to handle your pivot table because the columns are not known at design time. SSRS has feature called Matrix
that will handle the pivot a run time based off run time data if your design time structure is static.
ID | ColumnName | Value
------------------------
1 | Colu1 | Value1
1 | Colu2 | Value2
2 | Colu2 | Value2
I would recommend that you return detail rows from TSQL and allow SSRS to handle the pivot. This will allow for one stored procedure to be used for multiple SSRS reports and aggregations instead of the single aggregation provide by PIVOT
.
To save on duplicate processing, Matrix
will also handle the sorting so no need to sort inside of TSQL.
Reference: Create a Matrix
edited 14 hours ago
answered 14 hours ago
rschoenbach
713
713
So currently my query returns data in the form I listed above. You want me to write a query in the format - ID | Column | Value and then use a matrix in SSRS?
– JackSmith
14 hours ago
SSRS does a wonderful job at runtime pivot tables. Yes, I would write the query with the above structure and use a matrix.
– rschoenbach
14 hours ago
Ok I wrote the query to get the data in the following format. However I need one little change. The query is select distinct pApps.ApplicationID, ppl.LastName As ColName, isnull(ev.AnswerNumeric, 0) as ColValue from pApps inner join ev on pApps.SomeColumn = ev.SomeColumn inner join ppl on pApps.SomeColumn = ppl.SomeColumn Order By ApplicationID I need to add a total column as well. The data is coming out as ApplicationID | ColName | ColValue 12 | A | 5 12| B | 9 14 | A | 12 14 | B | 3 I need to add a total for each application that is the sum of A & B
– JackSmith
13 hours ago
@JackSmith SSRSMatrix
has the ability to create a total row for you. Reference
– rschoenbach
13 hours ago
Ok great thanks
– JackSmith
13 hours ago
add a comment |
So currently my query returns data in the form I listed above. You want me to write a query in the format - ID | Column | Value and then use a matrix in SSRS?
– JackSmith
14 hours ago
SSRS does a wonderful job at runtime pivot tables. Yes, I would write the query with the above structure and use a matrix.
– rschoenbach
14 hours ago
Ok I wrote the query to get the data in the following format. However I need one little change. The query is select distinct pApps.ApplicationID, ppl.LastName As ColName, isnull(ev.AnswerNumeric, 0) as ColValue from pApps inner join ev on pApps.SomeColumn = ev.SomeColumn inner join ppl on pApps.SomeColumn = ppl.SomeColumn Order By ApplicationID I need to add a total column as well. The data is coming out as ApplicationID | ColName | ColValue 12 | A | 5 12| B | 9 14 | A | 12 14 | B | 3 I need to add a total for each application that is the sum of A & B
– JackSmith
13 hours ago
@JackSmith SSRSMatrix
has the ability to create a total row for you. Reference
– rschoenbach
13 hours ago
Ok great thanks
– JackSmith
13 hours ago
So currently my query returns data in the form I listed above. You want me to write a query in the format - ID | Column | Value and then use a matrix in SSRS?
– JackSmith
14 hours ago
So currently my query returns data in the form I listed above. You want me to write a query in the format - ID | Column | Value and then use a matrix in SSRS?
– JackSmith
14 hours ago
SSRS does a wonderful job at runtime pivot tables. Yes, I would write the query with the above structure and use a matrix.
– rschoenbach
14 hours ago
SSRS does a wonderful job at runtime pivot tables. Yes, I would write the query with the above structure and use a matrix.
– rschoenbach
14 hours ago
Ok I wrote the query to get the data in the following format. However I need one little change. The query is select distinct pApps.ApplicationID, ppl.LastName As ColName, isnull(ev.AnswerNumeric, 0) as ColValue from pApps inner join ev on pApps.SomeColumn = ev.SomeColumn inner join ppl on pApps.SomeColumn = ppl.SomeColumn Order By ApplicationID I need to add a total column as well. The data is coming out as ApplicationID | ColName | ColValue 12 | A | 5 12| B | 9 14 | A | 12 14 | B | 3 I need to add a total for each application that is the sum of A & B
– JackSmith
13 hours ago
Ok I wrote the query to get the data in the following format. However I need one little change. The query is select distinct pApps.ApplicationID, ppl.LastName As ColName, isnull(ev.AnswerNumeric, 0) as ColValue from pApps inner join ev on pApps.SomeColumn = ev.SomeColumn inner join ppl on pApps.SomeColumn = ppl.SomeColumn Order By ApplicationID I need to add a total column as well. The data is coming out as ApplicationID | ColName | ColValue 12 | A | 5 12| B | 9 14 | A | 12 14 | B | 3 I need to add a total for each application that is the sum of A & B
– JackSmith
13 hours ago
@JackSmith SSRS
Matrix
has the ability to create a total row for you. Reference– rschoenbach
13 hours ago
@JackSmith SSRS
Matrix
has the ability to create a total row for you. Reference– rschoenbach
13 hours ago
Ok great thanks
– JackSmith
13 hours ago
Ok great thanks
– JackSmith
13 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416269%2fssrs-report-from-a-pivot-query-with-unknown-number-of-columns%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown