Forum Discussion

CMMaliniJoshi's avatar
3 years ago
Solved

Dynamic Columns Specification in CSV.Document

Dear All Kindly help me with a workaround in power query for below mentioned situation. I have to combine two reports in CSV. Both of the CSVs have top three rows which I need to remove first. F...
  • v-jingzhang's avatar
    v-jingzhang
    3 years ago

    Hi CMMaliniJoshi 

     

    I create a sample according to your description. You may download my sample file to see the solution. The files I used are in the zip file. 

    Please notice: in "Field Names" query, you need to have multiple rows for columns that have same kind of data but different names in CSVs.

    In "RequiredFields of Report1(Report2)", it should have all required field names in a single column. 

    For each report data query, we can provide a large enough number (e.g. 20 in my sample) for the "Columns" parameter in Csv.Document. This number should be larger than the possible maximum no. of columns in the future. Then remove top 3 rows, promote the first row as headers, select only required columns and rename these columns. Then append two queries into a single query to combine the data. 

    Change column data types in the combined query after you get all data for futher modeling/calculation. 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.