Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Add rows with missing dates in Power Query

Good morning, I need to add the missing dates to the attendance list for each employee.


I have below information in my table

Employee ID
Month-Year,

Date,

Time in and Time Out


Thank you all very much!

14 Replies

  • Daniel29195's avatar
    Daniel29195
    Community Champion

    Hello Anonymous 

     

    create a dimdate  ( you can from here ) https://radacad.com/all-in-one-script-to-create-date-dimension-in-power-bi-using-power-query

     

    then in power query, select the attendance table , and merge it with the dimdate . 

    choose the join type to be left join to dimdate . ( this way you get everything in dimdate that does not exist in your table ) . 

     

     

     

    1 --> your table

    2--> dimdate table 

    3-->  right join 

     

     

    let me know if it works for you . 

     

    NB (  you need to join with dimdate table having only dates for today's date so that you only return the dates missing until todays an not until end of year 2024 ) so maybe the dimdate created needs some minor tweaking . 

     

     

     

     

    If this answers your question  ,  mark it as the solution āœ… so can you can help  other people in the community find it easily . 

     

     

  • Can you please share your demo input and expected output!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Ahmedx ,

      Input Data

      Employee IDDateTime InTime Out
      10027-12-202310 AM5 PM
      10031-12-20239 AM7 PM
      20027-12-2029 AM3 PM
      20031-12-20239 AM9 PM


      Output

      Employee IDDateTime InTime Out
      10001-12-2023  
      20001-12-2023  
      10002-12-2023  
      20002-12-2023  
      10003-12-2023  
      20003-12-2023  
      10004-12-2023  
      20004-12-2023  
       ..  
       ..  
      10022-12-2023  
      20022-12-2023  
      10023-12-2023  
      20023-12-2023  
      10024-12-2023  
      20024-12-2023  
      10025-12-2023  
      20025-12-2023  
      10026-12-2023  
      20026-12-2023  
      10027-12-202310 AM5 PM
      20027-12-20239 AM3 PM
      10028-12-2023  
      20028-12-2023  
      10029-12-2023  
      20029-12-2023  
      10030-12-2023  
      20030-12-20239 AM7 PM
      10031-12-20239 AM7 PM
      20031-12-20239 AM9 PM

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Input Data

      Employee IDDateTime InTime Out
      10027-12-202310 AM5 PM
      10031-12-20239 AM7 PM
      20027-12-2029 AM3 PM
      20031-12-20239 AM9 PM


      Output

      Employee IDDateTime InTime Out
      10001-12-2023  
      20001-12-2023  
      10002-12-2023  
      20002-12-2023  
      10003-12-2023  
      20003-12-2023  
      10004-12-2023  
      20004-12-2023  
       ..  
       ..  
      10022-12-2023  
      20022-12-2023  
      10023-12-2023  
      20023-12-2023  
      10024-12-2023  
      20024-12-2023  
      10025-12-2023  
      20025-12-2023  
      10026-12-2023  
      20026-12-2023  
      10027-12-202310 AM5 PM
      20027-12-20239 AM3 PM
      10028-12-2023  
      20028-12-2023  
      10029-12-2023  
      20029-12-2023  
      10030-12-2023  
      20030-12-20239 AM7 PM
      10031-12-20239 AM7 PM
      20031-12-20239 AM9 PM

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Ahmedx , thanks for the quick solution.
      I need all the missing days for the month.
      Also, I added one more user to the solution, giving some errors..

      • Ahmedx's avatar
        Ahmedx
        Super User

        post an example and show what result you are expecting