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
Mike_Allen_MU
Regular Visitor

Add/Append column header (title) to new row

My apologies is this has already been answered.  I tried looking but could not find anything close enough to get me past where I am stuck.  I also pre-apologize in case my question is clear as mud. 

 

My goal is to append or add a variable number of column names (or headers) to the rows so I can get the full accounting string for entry posting.  Below is an image, where we have the funding source across the columns and the rest of the accounting information is in columns B&C in each row.  So the goal is to end up with fund/org(columnB)/account(ColumnC)/account name(columnD)/amount.

 

Original forms look like this and there are multiple tabs across multiple files like this.  And the number of Columns with fund numbers is variable and can be anywhere between 1 and 5 columns, although they always start in Column E.  So basically the forms are all the same except the width will vary based on the number of funds used.  

 

Mike_Allen_MU_0-1651255451960.png

 

Desired output would look something like this:

Mike_Allen_MU_1-1651256162719.png

 

Going to post a CSV version of one tab at the bottomr of the message in case that is helpful.  Any help pointing me the in right direction would be greatly appreciated.  

 

Thanks in advance,

 

Mike

 

   Budget Unit: BU05    College of Whatever
   Org: 2500    Department ABC
          
   Fund:119014200000199000701101309101Prior Year
   Return to Summary by Org    Expenditures
   Sources of funding      
BU0525005T00105T0010 Operating Allocation########     
BU0525005TDR105TDR10 Transfer from Dept Reserve $-   ########    
BU0525005T00505T0050 Internal - Unit Temp Transfer $-    ########   
BU0525005T00515T0051 Internal-Unit Personal Services Trf $-     ########  
BU0525005T00555T0055 Unit to Unit Temp Transfer $-      ######## 
BU052500536710536710 State Grants & Contracts######################################## 
BU052500546710546710 Local Grants & Contracts######################################## 
BU052500556702556702 Private Contracts $-   ########    
BU052500556710556710 Private Grants $-    ########   
BU052500596966596966 Miscellaneous - General $-     ########  
BU0525005R05105R0510 Reimbursement - Miscelleanous $-      ######## 
BU052500   $-        
BU052500   $-        
BU052500   $-        
BU052500   $-        
BU052500   $-        
   Total Sources######################################## $-   
    Please increase sources or decrease expenditures to balance.  
   Temporary Labor      
BU05250060015Graduate Assistants $-   ########    $-   
BU05250060016Student Assistants $-    ########   $-   
BU05250060019Work Study $-     ########  $-   
BU05250060017Part Time Faculty $-      ######## $-   
BU05250060018Casual Help $-   ########    $-   
BU05250060023Classified Temporary $-    ########   $-   
BU0525006001C2Faculty Summer Term $-     ########  $-   
BU0525006001FOvertime $-      ######## $-   
BU0525006001RFaculty Research $-        $-   
BU0525006001SStipends########    ########
BU0525006001TCell Phone Stipend $-       $660.00
BU0525006001UInternet Stipend $-       $180.00
BU0525006999BBenefits Temporary Labor $-       ########
   Total Temporary Labor################################################
          
   Direct Expenditures      
BU05250070024Computers $-        $-   
BU05250070024Contractual Services $-        $-   
BU05250070024Deferred Maintenance $-        $-   
BU05250070024Equipment $-        $-   
BU05250070024Functional Travel $-        $-   
BU05250070024Information Technology $-        $-   
BU05250070024Lab Expenses $-        $-   
BU05250070024Memberships & Accreditations $-       $300.00
BU05250070024MURC Positions $-        $-   
BU05250070024Office Expense $-       ########
BU05250070024Other Functional Expense $-       ########
BU05250070024Renovations & Repairs $-        $-   
BU05250070024Research Expenses $-        $-   
BU05250070024Scholarships $-        $-   
BU05250070024Software $-        $-   
BU05250070024Student Activities $-        $-   
BU05250070024Training & Development########     $-   
BU05250070021Utilities $-        $-   
BU05250070009Budget Future Commitment $-        $-   
BU05250071531Debt Service Principal $-        $-   
BU05250071541Interest on Debt Service $-        $-   
BU05250070280Inter-Agency Agreement-Indirect Cost $-        $-   
   Total Direct Expenditures######## $-    $-    $-    $-   ########
          
   Total Uses################################################
   Net Total - Sources less Uses################################################
1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Mike_Allen_MU ,

 

Is this what you want?

let
    Source = Csv.Document(File.Contents("C:\Users\Admin\Desktop\Mike.csv"),[Delimiter=",", Columns=10, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Removed Columns" = Table.RemoveColumns(Source,{"Column1", "Column10"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([Column4] <> "" and [Column4] <> "Budget Unit: " and [Column4] <> "Org: ")),
    #"Promoted Headers" = Table.PromoteHeaders(#"Filtered Rows", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"", Int64.Type}, {"_1", type text}, {"Fund:", type text}, {"119014", type text}, {"200000", type text}, {"199000", type text}, {"701101", type text}, {"309101", type text}}),
    #"Filtered Rows1" = Table.SelectRows(#"Changed Type", each ([_1] <> "")),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Filtered Rows1", {"", "_1", "Fund:"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Fund"}, {"Value", "Amount"}, {"Fund:", "Account Name"}, {"_1", "Account"}, {"", "Org"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Fund", "Org", "Account", "Account Name", "Amount"})
in
    #"Reordered Columns"

Icey_1-1651562681218.png

For more details, check the attachments.

 

 

Best Regards,

Icey

 

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

4 REPLIES 4
Icey
Community Support
Community Support

Hi @Mike_Allen_MU ,

 

Is this what you want?

let
    Source = Csv.Document(File.Contents("C:\Users\Admin\Desktop\Mike.csv"),[Delimiter=",", Columns=10, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Removed Columns" = Table.RemoveColumns(Source,{"Column1", "Column10"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([Column4] <> "" and [Column4] <> "Budget Unit: " and [Column4] <> "Org: ")),
    #"Promoted Headers" = Table.PromoteHeaders(#"Filtered Rows", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"", Int64.Type}, {"_1", type text}, {"Fund:", type text}, {"119014", type text}, {"200000", type text}, {"199000", type text}, {"701101", type text}, {"309101", type text}}),
    #"Filtered Rows1" = Table.SelectRows(#"Changed Type", each ([_1] <> "")),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Filtered Rows1", {"", "_1", "Fund:"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Fund"}, {"Value", "Amount"}, {"Fund:", "Account Name"}, {"_1", "Account"}, {"", "Org"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Fund", "Org", "Account", "Account Name", "Amount"})
in
    #"Reordered Columns"

Icey_1-1651562681218.png

For more details, check the attachments.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Icey,

 

Thanks again for all your assistance.  I think I will mark this as complete, as you answered the question in reguards to a single tab which is very useful and informative.  However I need to have the appended funding information be able to change from worksheet to worksheet (in the original excel files).  Thanks to your help, I think I am better able to ask my question.  So I will make this as complete and start a new thread for doing this same query across multiple pages in an excel spreadsheet and post a pbix example.

 

Thanks so much for your assistance Icey!!

 

Mike

 

Thank you for your reply and assistance Icey, you are very kind.  Your solution is almost exactly what I need.  However I need the column names (funds) to be dynamic as they are often different on every sheet.  So instead of hard coding 

#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"", Int64.Type}, {"_1", type text}, {"Fund:", type text}, {"119014", type text}, {"200000", type text}, {"199000", type text}, {"701101", type text}, {"309101", type text}})

If the 119014, 200000, 199000, 701101, 309101 could just refence the column number (aka 5,6,7,8,9) or something like that, then it would work for any range of funds and fit all sheets with a maximum of 5 funding sources (IE 5 columns).  

 

Thanks again for all your help and effort, it is greatly appreciated,

 

Mike

Hi @Mike_Allen_MU ,

 

How about changing types in the last step like so:

let
    Source = Csv.Document(File.Contents("C:\Users\Admin\Desktop\Mike.csv"),[Delimiter=",", Columns=10, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Removed Columns" = Table.RemoveColumns(Source,{"Column1", "Column10"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([Column4] <> "" and [Column4] <> "Budget Unit: " and [Column4] <> "Org: ")),
    #"Promoted Headers" = Table.PromoteHeaders(#"Filtered Rows", [PromoteAllScalars=true]),
    #"Filtered Rows1" = Table.SelectRows(#"Promoted Headers", each ([_1] <> "")),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Filtered Rows1", {"", "_1", "Fund:"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Fund"}, {"Value", "Amount"}, {"Fund:", "Account Name"}, {"_1", "Account"}, {"", "Org"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Fund", "Org", "Account", "Account Name", "Amount"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Reordered Columns",{{"Fund", Int64.Type}, {"Org", Int64.Type}, {"Account", type text}, {"Account Name", type text}, {"Amount", type text}})
in
    #"Changed Type"

Icey_0-1651652487905.png

 

Best Regards,

Icey

 

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.