In details window, select resources needed to complete the task.
For human resources, the Units coefficient shows the part of its working program dedicated to the current task (e.g. if the resource have an 8 hours per day program and you set 0.5 units, the resource will spend 4 hours per day working at that task).
For materials, Units gives the quantity needed to complete the task.
While assigning resources, the work on task is displayed at the bottom (also in the table, Work column).
To keep the work and change the duration when changing resources (assign a new resource, remove a resource, change the units for an assigned resource), just mark the Keep the amount of work when changing resources (make task work-driven) checkbox (also at the bottom side).
The work needed to complete a task can be changed in the corresponding column of the table. In this case, the task duration will be changed to accomodate the work and the assigned resources. Attention: to set a work value for a task and keep it while asigning resources, first assign at list one resource, then mark the checkbox to make task work-driven and finally set the target value in the Work column. After that, any resource change will not affect the work value.