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
drogzy
Helper I
Helper I

Unpivot columns while connected with Direct Query

Hi all, 

 

Is there a way to unpivot columns in power query while the data connected is using direct query? 

 

I have seen an example (powerbi - Is it possible to unpivot in Power BI using DAX? - Stack Overflow) using UNION but my case is not related to calendar tables. See image below where my ID column has a duplicate for almost every row. That is the one I am right clicking to unpivot other columns

 

 

exampl.PNG

 

The issue here is that because of direct query this cannot be done the usual way because it pops an error code like so: 

 

exampl1.PNG

 

Is there a way around this? 

 

Appreciate any suggesstions @AlexisOlson @amitchandak 

1 ACCEPTED SOLUTION

Here's a simpler example.

 

Do this:

AlexisOlson_0-1648225652727.png

to get this:

AlexisOlson_1-1648225675013.png

View solution in original post

7 REPLIES 7
AlexisOlson
Super User
Super User

It's definitely possible to unpivot in the query editor without breaking DirectQuery. It looks like you're trying to pivot though. This is also possible but it gives this error if you choose an aggregation other than min/max/avg/sum that it can easily translate back into a native query. Try picking one of those instead of Don't Aggregate.

 

AlexisOlson_0-1648142674893.png

First I hit Unpivot from other columns on the ID column. 

Then I hit pivot on the attributes column, select values and then on advanced options I select don't aggregate. 

 

This essentially gives me what I want which is to go from 2 rows that have same ID but the columns have info separately to one row with info smuged together as long as one row is null....the only issue is the direct query is broken. It actually breaks as soon as I hit unpivot from other columns. 

 

Those options (sum, max, min) don't show up for me, this is what I see: 

 

exampl.PNG 

Appreciate your help on this!

Hmmm. I think maybe it's because it isn't a number column. 

 

What is the purpose behind unpivoting and pivoting? What are you ultimately trying to do?

I am trying to make rows (typically 2) that have same ID become one because in most cells in these rows the info is duplicated;  or null in one and data in the other. 

 

recent.PNG

 

 

I was using the pivot/unpivot just because I saw from another thread suggestion. It does what I want but it breaks the direct query. 

Maybe try grouping by the ID column and take the maximum over the others.

Sorry, I am not sure what you mean

Here's a simpler example.

 

Do this:

AlexisOlson_0-1648225652727.png

to get this:

AlexisOlson_1-1648225675013.png

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.