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
CH_MJR79
Helper II
Helper II

What is the best way of transforming this data?

Hello all. I was wondering if I could get some help on how best to transform some data.

 

I have an export from some accounts software that I would like to create some Power BI visualisations on.

 

This is a sample of the data from the Excel sheet. It shows different account codes and descriptions, along with totals for each of those accounts for 2023, 2022, 2021 and 2020.

 

AccountDescriptionYear End 30/6/2023Year End 30/6/2022Year End 30/6/2021Year End 30/6/2020
1Sales-1314413.96-1105903.5-1093038.37-950788.89
7Third-party sales-6729.295229.13-4343.42-2221.34
44Wages143008.39526602.99448520.9425935.17
53Sub contractors10498930543502115.99
131Bank account interest-473.61-35.04-120.65-76.28
229Rent28000280002800028000
230Rates and water3543.374304.983302.462916.25
232Insurance21613.6617394.716806.5615286.22
233Light and heat4678.094123.233487.262288.92

 

For example I would like to create a line chart visual which shows the increase in sales from 2020 to 2023.

 

Many thanks in advance.

 

 

 

 

1 ACCEPTED SOLUTION
zenisekd
Super User
Super User

In Power Query select the first two columns and then rightclick on the headers and select "unpivot other columns. This way you willl transform the table in such a way that you will get columns: Account, Description, YearEnd, ValueOfYearEnd. This way you can easily create visuals in Power BI Desktop. 


Kudos and Mark as solution appreciated.

View solution in original post

5 REPLIES 5
Arul
Super User
Super User

@CH_MJR79 ,

Follow these steps in Power Query Editor (refer the attached pbix file),

  1. Unpivot Columns: In this step, all columns except "Account" and "Description" needs to be unpivoted. 

  2. Extract Text Using Range: Here, a transformation is applied to the "Attribute" column. It extracts a substring of text from each cell in the "Attribute" column, starting from the 9th character and spanning 18 characters.

  3. Rename Columns: Rename the "Attribute" column to "Date" and the "Value" column to "Sales".

  4. Change Data Type with Locale: Finally, the "Date" column needs to be transformed into a date type with a specified locale (English India).

  5. Then, Close and Apply the changes.

Arul_0-1708423107854.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


@Arul Thank you for responding.

 

In the sample data, only the first row relates to the Sales account. The other 8 rows are unrelated to the first row.

 

From looking at the steps and the .pbix file all the values have been placed into the Sales column.

 

For account code '1 - Sales' the line chart would show the 4 years across the X-Axis and the values of -950788.89, -1093038.37, -1105903.50, -1314413.96 plotted on the Y-Axis.

 

For account code 131 - Bank account interest, the line chart would show the 4 years across the X-Axis and the values of -76.28, -120.65, -35.04 and -473.61 plotted on the Y-Axis.

 

For account codes 230 - Rates and water, 232 - Insurance, and 233 Light and heat, these would need to be grouped so the total for each year would be the three yearly figures for each of the three accounts combined.

 

This is how each graph would look (mocked up in Excel):

 

Sales:

CH_MJR79_0-1708427931688.png

 

Bank Account Interest:

CH_MJR79_1-1708427957921.png

 

Rates-Insurance-Light:

CH_MJR79_2-1708427986471.png

 

 

 

@CH_MJR79 ,

You just need to duplicate the same visual and apply visual level filters,

Arul_0-1708429548443.png

Please refer the attached file.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


zenisekd
Super User
Super User

In Power Query select the first two columns and then rightclick on the headers and select "unpivot other columns. This way you willl transform the table in such a way that you will get columns: Account, Description, YearEnd, ValueOfYearEnd. This way you can easily create visuals in Power BI Desktop. 


Kudos and Mark as solution appreciated.

This seems to have done it.

I've been able to create the Sales line chart that I wanted also.

Now onto the other visuals.

 

Thanks again to @zenisekd and @Arul 

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.