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

Pivot tables help

Greetings Community. I'm having problems with pivoting tables.

 

I have a talbe like this

 

pregunta.JPG

 

City name as headers, the following row has the name of the country that city belongs to. I wish to make a table where I can have a column for date, a column for city, a column for country and a column for the values (followers). Like this:

 

pregunta2.JPG

 

I'd really appreciate your help on this please.

 

Thanks in advance

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

For you scenario, I have create a table similar with your farmat.

 

Assuming that you have a table like below.

Fecha A1 A2
  country1 country2
01/01/2018 10  
01/02/2018 20  
01/03/2018   10
01/04/2018 25  
01/05/2018 25 30

 

1. Get data and go to Query edit.

 

2. Duplicate the table and unpviot the columns.

 

More details you could have a reference of the Applied steps in Query Editor for the attached pbix.

 

Here is the result.

 

result table.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

7 REPLIES 7
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

You may could use Unpivot column in Query Editor.

 

If you still need help, please share some data sample.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello @v-piga-msft, thanks for the quick response.

 

This is a piece my excel fille

 

pregunta3.JPG

 

I wish to make it look like this on Power BI:

Pregunta4.JPG

 

I have tried to unpivot that column, but when I do that I get this:

 

Pregunta5.JPG

 

So I lose the number value.

 

Thanks in advance.

Hi @Anonymous,

 

For you scenario, I have create a table similar with your farmat.

 

Assuming that you have a table like below.

Fecha A1 A2
  country1 country2
01/01/2018 10  
01/02/2018 20  
01/03/2018   10
01/04/2018 25  
01/05/2018 25 30

 

1. Get data and go to Query edit.

 

2. Duplicate the table and unpviot the columns.

 

More details you could have a reference of the Applied steps in Query Editor for the attached pbix.

 

Here is the result.

 

result table.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello @v-piga-msft, thanks for the help.

 

That's exactly the table I would like to get! But for some reason I cannot.

 

This is my data in query editor, prior to unpivoting columns. Just to clarify, the first few months of 2016 are all null.

 

Pregunta6.JPG

 

In query editor, the steps I'm following are:

 

1. Selecting all columns

2. Unpivot columns 

 

And this is what I get

 

Pregunta7.JPG

 

I tried selecting every column except the Date column and this is what I get:

 

Pregunta8.JPG

 

Sadly this is not looking as the table in your last post which is exactly how I'd like to get it.

 

Thanks again for all the help

 

Best regards

Hi @Anonymous,



This is my data in query editor, prior to unpivoting columns. Just to clarify, the first few months of 2016 are all null.

 

Pregunta6.JPG

 

 


 

 

Please have a try with the steps in the Query Editer for the test pbix I attached last reply.

 

For you scenario, if your first few months of 2016 are all null, I'm afraid the related date rows will disappear after unpivot.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hey @v-piga-msft, I really appreciate your help.

 

I tried using your pbix file but sadly it rpesents an error

 

DataSource.Error: Could not find a part of the path 'C:\Users\cherryg\Desktop\Book2.xlsx'.

 

So I can only see the table already with the format, Can't see the process of how you got it to look like that.

 

Thanks in advance

Hi @Anonymous,

 

You could copy my data sample which I pasted in the first reply to your excel and change the data source as yours in Advanced Editor in Query Editor.

 

Then you could refer to the steps.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.