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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Jasmine07
Regular Visitor

Power BI Pivot Columns ?

Hi all,

I’m trying to pivot two columns in my dataset in Power BI. While retaining all values exactly as they are, even if they are repeated (i.e. no aggregation such as sum or average).


However, when I select the columns in Power Query, the Pivot Columns option is disabled and I can only choose Unpivot Columns.

I’ve searched through Copilot and community posts for a solution, but when I copy the suggested M code into the Advanced Editor, I encounter a syntax error starting from the first line.

 

Could someone help me understand:

  • Why these columns cannot be pivoted in Power BI, and
  • What I might be doing wrong with the code or approach?

Thanks in advance for your help.

 

Jasmine07_10-1772678033613.png

 

Jasmine07_1-1772677882252.png

Jasmine07_0-1772677304979.png

 

1 ACCEPTED SOLUTION
cengizhanarslan
Super User
Super User

From your screenshot, your query already ends with:

 in
#"Renamed Columns2" 
 

Then you pasted another let ... in ... block underneath. Power Query can only have one let … in … per query. So you must either:

  • Replace the entire query with the new code, or

Create a New Query and paste the code there.

Seems like your problem lies in here.

 

So instead of mixing the code in a wrong way try using the UI of power query. Also could help if you share your .pbix or full code.

  1. In Power Query Editor, select the column that should become the new column headers.
  2. Go to Transform → Pivot Column.
  3. Choose the column that contains the values.
  4. Select an aggregation (usually Sum, Max, or Don't Aggregate if each key is unique).
_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

2 REPLIES 2
cengizhanarslan
Super User
Super User

From your screenshot, your query already ends with:

 in
#"Renamed Columns2" 
 

Then you pasted another let ... in ... block underneath. Power Query can only have one let … in … per query. So you must either:

  • Replace the entire query with the new code, or

Create a New Query and paste the code there.

Seems like your problem lies in here.

 

So instead of mixing the code in a wrong way try using the UI of power query. Also could help if you share your .pbix or full code.

  1. In Power Query Editor, select the column that should become the new column headers.
  2. Go to Transform → Pivot Column.
  3. Choose the column that contains the values.
  4. Select an aggregation (usually Sum, Max, or Don't Aggregate if each key is unique).
_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.
grazitti_sapna
Super User
Super User

Hi @Jasmine07,

 

Issue is that as there are multiple values against attributes, power BI doesn't recognise them, the best way is to create each value as unique

 

U can achieve it by adding an Index and group column in your table.

Adding index column Transform → Add Column → Index Column → From 0

then add a group column 

Add Column → Custom Column

enter this m code Number.IntegerDivide([Index],3)

 

U'll get output like this 

 

Attributes Values Index GroupID
A1 V1 0 0
A2 V2 1 0
A3 V3 2 0
A1 V4 3 1
A2 V5 4 1
A3 V6 5 1
A1 V7 6 2
A2 V8 7 2
A3 V9 8 2

 

Then pivot the columns, you'll get the final output like this

 

GroupID A1 A2 A3
0 V1 V2 V3
1 V4 V5 V6
2 V7 V8 V9

 

Now you can simply remove th group ID column.

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.