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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Help with Pivot in Power Query

Hi everyone ! 

 

I have a dataset like this:

Romain_L_0-1626337614769.png

Each MEMBER_ID represent a different field, i want to pivot this column.

No problem in doing this: 

Romain_L_1-1626337776228.png

The problem is the collumn's names, they can change in the dataset so i don't want to rename them manually as they will be errors if a field is missing. In order to fix that i have in another table the name linked to the id:

Romain_L_2-1626337971209.png

So with a Table.NestedJoin() i achieve this:

Romain_L_3-1626338208703.png

But now (after deleting the ID collumn), if i want to pivot: 

 = Table.Pivot(#"Colonnes supprimées2", List.Distinct(#"Colonnes supprimées2"[DB_Names.Name]), "DB_Names.Name", "Value", List.Sum)

It throws an error:

Romain_L_7-1626339414075.png

 

 

The strange part is if i add a Table.Distinct(#"Colonnes supprimées2", {"Date", "DB_Names.Name"}) just before pivoting, It works ! :

Romain_L_6-1626339161924.png

Of course i cant really do that as it does remove some data AND i have a bunch of other fields other than 'value' to include later.

 

Do you have some clues about what is happening ?

 

EDIT 1: I can now confirm it comes from the SQL request, as i copied the table before pivoting into a new report and i managed to pivot fine.

Here is the new copied report ( i cannot give you the sql request) : https://drive.google.com/file/d/1xiK0DjfC9EQrQ0Zr4G3nJsUcqAVqdYod/view?usp=sharing 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

So i figured it out ! before pivoting this collumn i had to make sure there wasn't any duplicates, and in my data set i have another collumn to pivot, i did the other one first and then it allowed my to pivot my 'names' collumn. This is not a problem with the operations but with the SQL query. I don't really know how it works but it seams to adapt the SQL query to your operations and couldn't figure out how to process this pivot without the other.
I wish there was some explanation about how power query really works in that regard, because it got me stuck and it took me some trial and error to figure it out.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

So i figured it out ! before pivoting this collumn i had to make sure there wasn't any duplicates, and in my data set i have another collumn to pivot, i did the other one first and then it allowed my to pivot my 'names' collumn. This is not a problem with the operations but with the SQL query. I don't really know how it works but it seams to adapt the SQL query to your operations and couldn't figure out how to process this pivot without the other.
I wish there was some explanation about how power query really works in that regard, because it got me stuck and it took me some trial and error to figure it out.

Fowmy
Super User
Super User

@Anonymous 

Can you share a sample PBIX file here, save it in OneDrive or any other location, and share the link here. 


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy  Hi,

I've edited the main post,

thx

@Anonymous 

What is the expected result based on your table below:

Fowmy_0-1626361236424.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.