Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Pivot table for Box Plot Chart data

$
0
0

Hi,

I have a table that I need to create a box plot chart.  The data contains percentage columns with range 0..100.  Sample table is as follows (I'm cutting the percentage to 5 columns only here as an illustration.):

CREATE TABLE BoxPlot (
  HUCCODE nvarchar(8),
  Name nvarchar(255),
  Prediction nvarchar(255),
  [P0] [decimal](18, 6) NULL,
    [P1] [decimal](18, 6) NULL,
    [P2] [decimal](18, 6) NULL,
    [P3] [decimal](18, 6) NULL,
    [P4] [decimal](18, 6) NULL
)

INSERT INTO BoxPlot(
 HUCCODE, Name, Prediction,
 P0, P1, P2, P3, P4
)
VALUES
('10040201', 'Cropland', 'Sediment',   0.000100,    0.000100,    0.000100,    0.000100,    0.000100),
('10040201', 'Cropland', 'Nitrogen', 0.001000,    0.001000,    0.001000,    0.001000,    0.001000),
('10040201', 'Cropland', 'Phosphorus',    0.000000,    0.000000,    0.000000,    0.000000,    0.000000),
('10040201', 'Cropland', 'WYLD',    0.000000,    0.000000,    0.010000,    0.010000,    0.010000),
('10040201', 'Forest', 'Sediment',   0.000100,    0.000100,    0.000100,    0.000100,    0.000100),
('10040201', 'Forest', 'Nitrogen', 0.001000,    0.001000,    0.001000,    0.001000,    0.001000),
('10040201', 'Forest', 'Phosphorus',    0.000000,    0.000000,    0.000000,    0.000000,    0.000000),
('10040201', 'Forest', 'WYLD',    0.010000,    0.010000,    0.010000,    0.010000,    0.010000),
('10040201', 'Pasture', 'Sediment',   NULL,    NULL,    NULL,    NULL,    NULL),
('10040201', 'Pasture', 'Nitrogen',    NULL,    NULL,    NULL,    NULL,    NULL),
('10040201', 'Pasture', 'Phosphorus',       NULL,    NULL,    NULL,    NULL,    NULL),
('10040201', 'Pasture', 'WYLD',       NULL,    NULL,    NULL,    NULL,    NULL),
('10040201', 'Rangeland', 'Sediment',   0.000100,    0.000100,    0.000100,    0.000100,    0.000100),
('10040201', 'Rangeland', 'Nitrogen',    0.001000,    0.001000,    0.004000,    0.006000,    0.009000),
('10040201', 'Rangeland', 'Phosphorus',       0.000000,    0.000000,    0.000000,    0.000000,    0.000000),
('10040201', 'Rangeland', 'WYLD',       0.000000,    0.020000,    0.090000,    0.170000,    0.280000),
('10040201', 'Urban', 'Sediment',   0.050000,    0.050000,    0.060000,    0.060000,    0.060000),
('10040201', 'Urban', 'Nitrogen',    2.480000,    2.766000,    3.209000,    3.327000,    3.378000),
('10040201', 'Urban', 'Phosphorus',       0.078000,    0.095000,    0.099000,    0.099000,    0.102000),
('10040201', 'Urban', 'WYLD',       21.710000,    22.660000,    25.150000,    25.750000,    26.130000)

My desired result is as follows:

HUCCODE      Name          PctCol          Sediment      Nitrogen      Phosphorus      WYLD
10040201    Cropland       P0               0.000100    0.001000    0.000000    0.000000    
10040201    Cropland       P1               0.000100    0.001000    0.000000    0.000000    
10040201    Cropland       P2              0.000100    0.001000    0.000000    0.010000    
10040201    Cropland       P3              0.000100    0.001000    0.000000    0.010000    
10040201    Cropland       P4              0.000100    0.001000    0.000000    0.010000
10040201    Forest           P0              0.000100    0.001000    0.000000    0.010000
10040201    Forest           P1              0.000100    0.001000    0.000000    0.010000
10040201    Forest           P2              0.000100    0.001000    0.000000    0.010000
10040201    Forest           P3              0.000100    0.001000    0.000000    0.010000
10040201    Forest           P4              0.000100    0.001000    0.000000    0.010000
etc...

I tried following some of the samples suggested here but I can't get this to work.

Appreciate any help.


Marilyn Gambone


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>