Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Fill up or down based on conditions

Hello everyone,   I need to complete some blanks in a table based on an id_employee and an id_week. If the first registry (by id_week) of an employee is blank it should be filled up with the follow...
  • artemus's avatar
    3 years ago

    The easy (but ugly) way of doing this is to:

    1. Create 3 index columns starting at 1,2,3

    2. Do a self merge with index column 2 and index column 1 as the join columns

    3. Do the same for index column 2 and index column 3.

    4. Expand the join columns.

    5. Rename the 2nd weekcategory column (the first join result) as "Prevweekcategory" similar for the id_employee

    6.Rename the 2nd weekcategory column (the first join result) as "Nextweekcategory" similar for the id_employee

     

    Now add a new column "Fixedweekcategory" with the logic to pick either the appropiate weekcategory based on if the current weekcategory is blank and if the current employee id matches the next or previous employee id.