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
donodackal
Helper I
Helper I

CSV Data Issue

Hello

 

I created a query that combines multiple CSV files from a SharePoint folder. All the CSV files have the same format where the header row data is a few rows below. On applying the query steps, I have deleted the first few rows and the relevant row is promoted to the header. My understanding is the same steps is applied to all files from the first file. Copied below is how the raw file looks and what I have deleted/promoted:

 

Rows I deletedReport NameSupplier Opportunities (by Supplier List)  
DescriptionShows RFx's offered to supplier and responses (only data entered after 1st March 2012 shown)
Date Range (GMT)From 01/Mar/2012 To 25/Jan/2022  
      
Supplier list selectedData    
      
      
Row I promoted to the headerSupplier Business NameActive On ListBusiness Number TypeBusiness NumberRfx NameRFx Reference
DataDataDataDataDataDataData
DataDataDataDataDataData
DataDataDataDataDataData
DataDataDataDataDataData

 

In the final output, the data is all fine but a few rows that I either deleted or promoted to as header is appearing in the data. See below:

Header >>Source file NameSupplier Business NameActive On List
Data>>Source file NameSupplier list selectedCreative Services Panel
Source file NameSupplier Business NameActive On List
Source file NameSupplier list selectedTraining Services Panel
Source file NameSupplier Business NameActive On List
Source file NameSupplier list selectedEmployees Assistance Program Panel
Source file NameSupplier Business NameActive On List
Source file NameSupplier list selectedMedical Services Scheme
Source file NameSupplier Business NameActive On List
Source file NameSupplier list selectedTerritory Valuation Services Scheme

Any help is appreciated. 

 

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @donodackal,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
sevenhills
Super User
Super User

I look your issue as dynamic row number for the header row. If you want to remove up to header rows of each file and later promote the column headers. There are multiple ways to solve it. 

Before you try my steps, Take a backup of your .pbix file.

Power BI creates the Transform file function. we are going to edit this function for your needs

(fx) -- Transform file

 

 

 

let
    Source = (Parameter1 as binary) => let
        Source = Csv.Document(Parameter1,[Delimiter=",", Columns=3, Encoding=1252, QuoteStyle=QuoteStyle.None]),
        #"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type),
        #"Added Conditional Column" = Table.AddColumn(#"Added Index", "Custom", each if [Column1] = "Region" then [Index] - 1 else null, Int32.Type),
        #"Filled Up" = Table.FillUp(#"Added Conditional Column",{"Custom"}),
        #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([Index] > [Custom] or [Custom] is null)),
        #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom", "Index"}),
        #"Promoted Headers" = Table.PromoteHeaders(#"Removed Columns", [PromoteAllScalars=true])
    in
        #"Promoted Headers"
in
    Source

 

 

 

You need to changes these lines as per your file content

a) [Column1] = "Region" ... replace "Region" with the text on column1, to identify the Data table header
b) Remove "Source.Name" in the query/table step that calls the transform file function

VijayP
Super User
Super User

@donodackal 

In Power Query what ever steps applied in first file ( in case of Folder with CSV Files), that will automatically takes care of other files. But in your case that is not happeing!

 

If you can share some sample data without classified information. I can help you!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


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.