Link to home
Start Free TrialLog in
Avatar of jnikodym
jnikodym

asked on

Power BI stacked column chart

I need to create a stacked column chart where on the x axis it lists employee names.  The employee name could be in two different columns in my data set.  I would like the stacked column to show each order for each employee by price.  Below is an example of the dataset.

Emp1    Emp2    price   Order
Joe         Jim         100     11111
Jim         Jim         200     22222
Bill         Joe         200     33333
Bill                        100    44444

I would want the x axis to have Joe, Jim and Bill listed and each to have a stacked column by price
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Order 1111 ::  would that be shown as $100 for Joe AND $100 for Jim

Is that correct?
Does this produce the expected data for your graph?

CREATE TABLE Table1
    ([Emp1] varchar(4), [Emp2] varchar(4), [price] int, [Order] int)
;
    
INSERT INTO Table1
    ([Emp1], [Emp2], [price], [Order])
VALUES
    ('Joe', 'Jim', 100, 11111),
    ('Jim', 'Jim', 200, 22222),
    ('Bill', 'Joe', 200, 33333),
    ('Bill', NULL, 100, 44444)
;

**Query 1**:

select Emp1, price, [order] from table1 where emp1 is not null
union all
select Emp2, price, [order] from table1 where emp2 is not null
order by emp1, price


| Emp1 | price | order |
|------|-------|-------|
| Bill |   100 | 44444 |
| Bill |   200 | 33333 |
|  Jim |   100 | 11111 |
|  Jim |   200 | 22222 |
|  Jim |   200 | 22222 |
|  Joe |   100 | 11111 |
|  Joe |   200 | 33333 |

[1]: http://sqlfiddle.com/#!6/537a08/2

Open in new window

Avatar of jnikodym
jnikodym

ASKER

It’s close. In this example I would only want Jim listed once.
I'm sorry, i meant in this example Jim should only be listed twice.  Once for Order 11111 and once for order 22222
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial