Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Add dynamic rows for each day

How to add dynamic rows for each day with the processor name as Tom, activity as Login, Quarter Hour as 7:15:00AM and activity duration as 25200 for the attached table? The same details should be added for each day of the month except weekends.

 

  • Hello Anonymous 

    We can use PowerQuery and just do a couple transformations to get what you are looking for.

    • Reference the original table
    • Keep only 1 row for each unique date
    • Add the day name column and delete the weekend days
    • Use extract first 0 characters to clear all the data in the other columns
    • Fill in the Tom data
    • Append on the original table

    I have saved an excel file example with the source data and the output table here: https://www.dropbox.com/s/y7109sh0ur9218x/AddTomRows.xlsx?dl=0

    Original dataTom + original data

4 Replies

  • v-yuta-msft's avatar
    v-yuta-msft
    Community Support

    Anonymous ,

     

    No, power query doesn't suppot adding specific rows, you can only append multiple tables in power query. In your senario, I would suggest you to export the data to database and insert rows using SQL statement like INSERT INTO TABLE VALUES(...).

     

    Community Support Team _ Jimmy Tao

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

      • v-yuta-msft's avatar
        v-yuta-msft
        Community Support

        Anonymous ,

         

        This is DAX function, not the power query code. The dax code you provided can only generate a temporary table in the report view level. So if you don't need to add rows in the raw table, you can use DAX fucntion.

         

        Community Support Team _ Jimmy Tao

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

  • Hello Anonymous 

    We can use PowerQuery and just do a couple transformations to get what you are looking for.

    • Reference the original table
    • Keep only 1 row for each unique date
    • Add the day name column and delete the weekend days
    • Use extract first 0 characters to clear all the data in the other columns
    • Fill in the Tom data
    • Append on the original table

    I have saved an excel file example with the source data and the output table here: https://www.dropbox.com/s/y7109sh0ur9218x/AddTomRows.xlsx?dl=0

    Original dataTom + original data