Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 89
  • Last Modified:

SSRS Graph - Stacked Bar

I am trying to create a Stacked Bar Graph in SSRS - i have the below data

Month      Q1              Q2               Q3               Q4
May            50.00%      20.00%      30.00%      0.00%
June            38.46%      30.77%      15.38%      15.38%
July            30.77%      38.46%      15.38%      15.38%
August  46.15%      7.69%      15.38%      30.77%

I want to have the stack by Q1 then the data be for each month, then Q2,Q3, Q4 and so on, I can easily do it in Excel (attached example) but cant reproduce in SSRS - hoping someone can help

Thanks

Book1.xlsx
0
dkilby
Asked:
dkilby
1 Solution
 
Nico BontenbalCommented:
I'm afraid that's not possible in SSRS. So you need to reformat your data so the columns are Month, Quarter, Value. If you use SQL Server you can do that using UNPIVOT. Suppose your original query was like this:
select 'May' as Month, 50 as Q1, 20 as Q2, 30 as Q3, 0 as Q4
union all
select 'June' as Month, 38 as Q1, 30 as Q2, 15 as Q3, 15 as Q4
union all
select 'July' as Month, 30 as Q1, 38  as Q2, 15 as Q3, 15 as Q4
union all
select 'August' as Month, 46 as Q1, 7 as Q2, 15 as Q3, 38 as Q4

Open in new window

(That's not what your query looks like of course, but the result has the same structure as your example.) Then you can move the 4 quarters into 1 column like this:
select Month, Quarter, Value  from 
(
select 'May' as Month, 50 as Q1, 20 as Q2, 30 as Q3, 0 as Q4
union all
select 'June' as Month, 38 as Q1, 30 as Q2, 15 as Q3, 15 as Q4
union all
select 'July' as Month, 30 as Q1, 38  as Q2, 15 as Q3, 15 as Q4
union all
select 'August' as Month, 46 as Q1, 7 as Q2, 15 as Q3, 38 as Q4
) as original
UNPIVOT (Value for Quarter IN (Q1, Q2, Q3, Q4)) as new

Open in new window

With this result you can create a chart using Value as Values, Quarter as Category Groups and Month as Series Groups.

Please let me know if you need any further help solving this issue.
0
 
dkilbyAuthor Commented:
Thanks, worked perfectly
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now