Forum Discussion

bestbestb's avatar
bestbestb
New Member
4 years ago

Pivot rows to columns with multiple values

Hi,

 

I want to pivot the "charge_name" column shown below with 10+ catagories: 

I need to pivot using two value fields, qty and amount respectively:

Here's how I did it:  I duplicated the charge name column and pivoted the columns using amount and quantity respectively.

I also had to change the pivoted column names otherwise i would get duplicate error when I do quantity.

 

Is there a better/smarter way to do this?

 

Any suggestion appreciated,

 

Thanks!

2 Replies

  • Ehren's avatar
    Ehren
    Microsoft Employee

    There may be a better way, but your approach is probably the one I would have taken.

  • Anonymous's avatar
    Anonymous
    Not applicable

    bestbestb 
    I don't know your solution step by step so it is hard to say. I cannot think of any better without any test. If you already have a solution, should stick with it. Simple pivot and unpivot steps would not slow the query speed.

     

     

    Paul Zheng _ Community Support Team