Forum Discussion

Ankitvardhan's avatar
Ankitvardhan
New Member
7 months ago
Solved

Tranform the data

Hi everyone

i have 30 person data in 30 excel files and each file consists of 52 week data sheets

Now i have selected a sample file and did some operations on them like cleaning and all. But i dont know how to make a function that perform sample file  working things  in all sheets of a file.

 

  • Hii Ankitvardhan 

    TO FIX  IT

     

    Step 1: Create the Sheet Transformation Function

    1. ​Open your Sample File and connect to one specific sheet.
    2. ​Perform all your cleaning steps (Removing rows, renaming headers, etc.).
    3. ​In the Queries pane (left side), right-click your sample query and select Create Function. Name it fnTransformSheet.

    Step 2: Connect to the Folder

    1. ​Go to Get Data > File > Folder.
    2. ​Point it to the folder containing your 30 Excel files.
    3. ​Click Transform Data (Do NOT click Combine yet).

    Step 3: Expand the Sheets

    ​Now, instead of clicking the "Combine" button in the Content column, we will manually expand the sheets so we can apply your function to every single one.

    1. ​Click the Add Column tab > Custom Column.
    2. ​Use the formula: = Excel.Workbook([Content]). This will create a new column containing "Table" objects of all sheets.
    3. ​Click the Expand icon (two arrows) on this new column and select only the Data and Item (Sheet Name) columns.
      • Now you have a row for every week (30 files × 52 weeks = 1,560 rows).

    Step 4: Invoke your Transformation Function

    1. ​Go to the Add Column tab > Invoke Custom Column.
    2. ​Select your function fnTransformSheet.
    3. ​For the input parameter, select the Data column (which contains the raw sheet content).
    4. ​Power Query will now run your "Sample" cleaning steps on all 1,560 sheets simultaneously.

    If this "Invoke Function" method successfully cleans all 52 weeks for your 30 people, please mark this as the "Accepted Solution"!

7 Replies

  • AshokKunwar's avatar
    AshokKunwar
    Continued Contributor

    Hii Ankitvardhan 

    TO FIX  IT

     

    Step 1: Create the Sheet Transformation Function

    1. ​Open your Sample File and connect to one specific sheet.
    2. ​Perform all your cleaning steps (Removing rows, renaming headers, etc.).
    3. ​In the Queries pane (left side), right-click your sample query and select Create Function. Name it fnTransformSheet.

    Step 2: Connect to the Folder

    1. ​Go to Get Data > File > Folder.
    2. ​Point it to the folder containing your 30 Excel files.
    3. ​Click Transform Data (Do NOT click Combine yet).

    Step 3: Expand the Sheets

    ​Now, instead of clicking the "Combine" button in the Content column, we will manually expand the sheets so we can apply your function to every single one.

    1. ​Click the Add Column tab > Custom Column.
    2. ​Use the formula: = Excel.Workbook([Content]). This will create a new column containing "Table" objects of all sheets.
    3. ​Click the Expand icon (two arrows) on this new column and select only the Data and Item (Sheet Name) columns.
      • Now you have a row for every week (30 files × 52 weeks = 1,560 rows).

    Step 4: Invoke your Transformation Function

    1. ​Go to the Add Column tab > Invoke Custom Column.
    2. ​Select your function fnTransformSheet.
    3. ​For the input parameter, select the Data column (which contains the raw sheet content).
    4. ​Power Query will now run your "Sample" cleaning steps on all 1,560 sheets simultaneously.

    If this "Invoke Function" method successfully cleans all 52 weeks for your 30 people, please mark this as the "Accepted Solution"!

  • AshokKunwar's avatar
    AshokKunwar
    Continued Contributor

    Hii Ankitvardhan 

     

    If this "Invoke Function" method successfully cleans all 52 weeks for your 30 people, please mark this as the "Accepted Solution"!