@Adrian73 welcome to the KNIME forum. Since I am on a mobile device I could not have a look at the solution by @victor_palacios. But it seems your example and the resulting data might not be fully consistent.
There have been similar data preparation tasks in the pastel you might want to take a look. And if you do not have a solution yet maybe amend your sample data.