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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ERing
Helper V
Helper V

Help with how can I transform this Excel data?

I've been given the Excel data below as a data source to use in a report. I need to transform the data so it's in a useful structure.

 

I know I can use "first row as headers" but I'm unsure what to do after that.

I need to get the data so that I have the following columns

1. Location

2. Month & year

3. Website visits

1.png

 

Expected Format

2.png

1 ACCEPTED SOLUTION
Bibiano_Geraldo
Memorable Member
Memorable Member

Hi, @ERing ,

Follow these steps to reach your goal:

You can learn more about Unpivot by the link: Unpivot columns 

 

1. Renove top 2 rows:

Bibiano_Geraldo_0-1731361506002.pngBibiano_Geraldo_1-1731361557703.png

2. Use first row as header:

Bibiano_Geraldo_2-1731361655729.png

3. Remove 2023 column:

Bibiano_Geraldo_3-1731361764892.png

 

4. Right click on top of Location column and then Unpivot Other columns:

Bibiano_Geraldo_4-1731361913417.png

 

5. Now your data should look like this:

Bibiano_Geraldo_5-1731362087885.png

 

Importante recomendations: Note that in the final result, you see months with suffixes like (Jan_1, Feb_2, etc.). This happens because when we promoted the first row to headers, Power Query added this index to prevent duplication in column names. While this is a good practice, in this case, we want the months as values, which is why we unpivoted the data. The suffix appears due to this. To fix this, I recommend renaming your Excel file columns to something like the example below:

 

Bibiano_Geraldo_6-1731362696460.png

 

You can learn more about Unpivot by the link: Unpivot columns 

If this Reply satisfies your needs, please mark it as solution and give a Kudo.

 

Thank you

I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 

View solution in original post

3 REPLIES 3
Bibiano_Geraldo
Memorable Member
Memorable Member

Hi, @ERing ,

Follow these steps to reach your goal:

You can learn more about Unpivot by the link: Unpivot columns 

 

1. Renove top 2 rows:

Bibiano_Geraldo_0-1731361506002.pngBibiano_Geraldo_1-1731361557703.png

2. Use first row as header:

Bibiano_Geraldo_2-1731361655729.png

3. Remove 2023 column:

Bibiano_Geraldo_3-1731361764892.png

 

4. Right click on top of Location column and then Unpivot Other columns:

Bibiano_Geraldo_4-1731361913417.png

 

5. Now your data should look like this:

Bibiano_Geraldo_5-1731362087885.png

 

Importante recomendations: Note that in the final result, you see months with suffixes like (Jan_1, Feb_2, etc.). This happens because when we promoted the first row to headers, Power Query added this index to prevent duplication in column names. While this is a good practice, in this case, we want the months as values, which is why we unpivoted the data. The suffix appears due to this. To fix this, I recommend renaming your Excel file columns to something like the example below:

 

Bibiano_Geraldo_6-1731362696460.png

 

You can learn more about Unpivot by the link: Unpivot columns 

If this Reply satisfies your needs, please mark it as solution and give a Kudo.

 

Thank you

I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 

This worked! Thanks!

vicky_
Super User
Super User

I would first delete the 2023 total column, as you will be able to calculate this later
Then i would go to Transform > Transpose
Select the columns with the locations and Unpivot other Columns

Then I would need to tidy up the header names manually

 

My PowerQuery Code looks like the below:

let
    Source = // your source here,
    #"Transposed Table" = Table.Transpose(Source),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"Column1", "Location"}, "Attribute", "Value")
in
    #"Unpivoted Columns"

My data looks like:

vicky__0-1731360000640.png

Note that because of the way your data is structured, when you click "transpose", the locations column is actually the header for the months (but this can easily be fixed by renaming the column)

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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