Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Create multiple columns from rows

Hello All,

I have the following table. My current key is a combination of ID & Type.  For each type, I have to get 7 columns with the following  schema (type + each following column) :

  • Coal Value Chain
  • Coal threshold type
  • Coal threshold value
  • Coal absolute
  • Coal relative
  • Coal new

.....

In this example, I want to end up with 8*6 columns (coal, oil, tobacco, other_fossil_fuel,cannabis,gas,unconventionnal_weapon,PORNOGRAPHY_ADULT_ENTERTAINMENT_SERVICES)*(value chain, threshold type, threshold value, absolute, relative, new) and two line, one for each ID (1000 and 1002).

IDTypeValue chainthreshold typethreshold valueabsoluterelativenew
1000COALU;P;DR0.2100.2Y
1000OILU;PCnullnullnullY
1000TOBACCOU;P;DR0.3nullnullnull
1000OTHER_FOSSIL_FUELU;PCnullnullnullY
1000CANNABISPR0.3nullnullnull
1000GASU;PCnullnullnullY
1000UNCONVENTIONAL_WEAPONSU;P;DR0nullnullnull
1002UNCONVENTIONAL_WEAPONSU;P;DR0nullnullnull
1002PORNOGRAPHY_ADULT_ENTERTAINMENT_SERVICESU;P;DR0.05nullnullnull
1002TOBACCOU;P;DR0.3nullnullnull
1002CANNABISPR0.3nullnullnull
1002COALU;P;DR0.2100.2Y
1002GASU;PCnullnullnullY
1002OTHER_FOSSIL_FUELU;PCnullnullnullY
1002OILU;PCnullnullnullY

 

I have tried to pivot columns... but I can't figure out how to deal with this. I am able to create the required columns but I can't find a way to group by ID so that I only get one row with the correct data.

 

Any idea on this? 

 

Thanks, 

Aryagon

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. In power query – select [schema] – Spliy Column – By Delimiter.

vyangliumsft_0-1692336972799.png

Split at : Left – most delimiter.

vyangliumsft_1-1692336972802.png

vyangliumsft_4-1692337007904.png

2. Select [schema.2] – Transform – Pivot Column.

Values Column – [Flag]

Aggreate Value Function – Don’t Aggregate

vyangliumsft_5-1692337019315.png

3. Result:

vyangliumsft_6-1692337019316.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. In power query – select [schema] – Spliy Column – By Delimiter.

vyangliumsft_0-1692336972799.png

Split at : Left – most delimiter.

vyangliumsft_1-1692336972802.png

vyangliumsft_4-1692337007904.png

2. Select [schema.2] – Transform – Pivot Column.

Values Column – [Flag]

Aggreate Value Function – Don’t Aggregate

vyangliumsft_5-1692337019315.png

3. Result:

vyangliumsft_6-1692337019316.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@Anonymous , You can create a new column with group values

example

 

Sumx(filter(table, Table[ID] = earlier(Table[ID])) , Table[threshold value] )

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks ! What about diplaying the correct Value chain, as sumx does not handle string values? 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.