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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
CLCrook
New Member

Normalize monthly financial records into multiple records for producing line graph

I have a table with denormalized data by month (could have multiple lines per vendor with additional monthly cost).

 

CLCrook_0-1733521796733.png

 

I need to create a traditional line chart with month on the x-axis and dollars on the y-axis based on filtering the data by various other fields in the table ("Source" == 'Budget') or ("Source" == 'Actual') for example. How can I do this in PowerQuery?

1 ACCEPTED SOLUTION
Chewdata
Resolver IV
Resolver IV

Hey,

You can Achievethis by selecting the P[no] FY2024 columns and select Unpivot Columns in the transform columns tab of Power Query. 
After that you can split the resulting Attribute column into both a Period and a Year Column.
I've used random values in the example.

Code snippet:

let
    Source = YOURDATA,
    UnpivColumns = Table.UnpivotOtherColumns(Source, {"Vendor"}, "Period", "Value"),
    SplitColumn = Table.SplitColumn(UnpivColumns, "Period", Splitter.SplitTextByDelimiter(" FY", QuoteStyle.Csv), {"Period", "Year"}),
    ChangeType = Table.TransformColumnTypes(SplitColumn,{{"Period", type text}, {"Year", Int64.Type}})
in
    ChangeType

 

outcome:

Chewdata_0-1733650255545.png

 

View solution in original post

5 REPLIES 5
v-cgao-msft
Community Support
Community Support

Hi @CLCrook ,

 

Did you find a solution? Did the above answers help? If so, mark the reply as a solution, which will help the next user with a similar problem, thank you~!

Best Regards,
Gao

Community Support Team

SacheeTh
Advocate III
Advocate III

To normalize your data for a line chart in Power BI, you need to unpivot the monthly columns into rows using Power Query. This transformation converts the wide table format (monthly data as columns) into a long format, with one column representing the months and another for the corresponding values (e.g., dollars).
After unpivoting, you can filter the data based on conditions like "Source == 'Budget'" or "Source == 'Actual'" and load it into Power BI.

Once transformed, you can create a line chart by assigning the unpivoted month column to the X-axis and the values column to the Y-axis. Ensure the month column is sorted chronologically, and apply any necessary filters to refine your visualization.
Else pivot back to the original state which will filter the columns you have filtered on the fitering stage.

Chewdata
Resolver IV
Resolver IV

Hey,

You can Achievethis by selecting the P[no] FY2024 columns and select Unpivot Columns in the transform columns tab of Power Query. 
After that you can split the resulting Attribute column into both a Period and a Year Column.
I've used random values in the example.

Code snippet:

let
    Source = YOURDATA,
    UnpivColumns = Table.UnpivotOtherColumns(Source, {"Vendor"}, "Period", "Value"),
    SplitColumn = Table.SplitColumn(UnpivColumns, "Period", Splitter.SplitTextByDelimiter(" FY", QuoteStyle.Csv), {"Period", "Year"}),
    ChangeType = Table.TransformColumnTypes(SplitColumn,{{"Period", type text}, {"Year", Int64.Type}})
in
    ChangeType

 

outcome:

Chewdata_0-1733650255545.png

 

Omid_Motamedise
Resident Rockstar
Resident Rockstar

Select all the columns, right click on one of them and pick unpivot other columns, then create a pivot table based on the result table.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors