Link to home
Create AccountLog in
Avatar of T B
T BFlag for Saudi Arabia

asked on

Power Query (Duplicating row based on 2 column value)

Dear Expert.


Can you please guide me to achieve this task in power query :-

I'm using power query, and having many tables in excel worksheet about student courses, one of the table name is (Required Courses) illustrates the following fields (Table # 1 - as mentioned below)


- Phase : Student Level (Bachelor or Diploma)
- LVL    : Student semester
- Course: Course Code
- Course Name
- Course Type : (General -OR- Specialist)
- Theoretical Classes : this column illustrates number of classes to be created to accommodate the number of student.
- Practical Classes : this column illustrates number of classes to be created to accommodate the number of student.


(Table # 1)

PhaseLVLCourseCourse typeTheoretical ClassesPractical Classes
BAUG1MTM-341Specialist1
BAUG2ANJ-302General11
BAUG2RYA-302General12
BAUG2MTM-322Specialist22



What I'm looking for is that power query would duplicate each records based on the numbers indicated in [Theoretical Classes] column or [Practical Classes] column, in addition to fill [Class Type] value if its Theoretical or Practical classes (as describe here below in Table # 2)


(Table # 2)

PhaseLVLCourseCourse typeClass TypeMy Comments
BAUG1MTM-341SpecialistTheoretical ClassesAs this Course is having nbr (1) in Theoretical Classes column in above Table # 1
BAUG2ANJ-302GeneralTheoretical ClassesAs this Course is having nbr (1) in Theoretical Classes column and nbr (1) in Practoical Classes , then its been repeat it twice , taking int consideration that Class Type is filled accordingly
BAUG2ANJ-302GeneralPractical Classes
BAUG2RYA-302GeneralTheoretical ClassesThis course having nbr (1) in Theoretical Classes column and nbr (2) in Practical Classes , then its been repeated 3 times and Class type is filled accordingly.
BAUG2RYA-302GeneralPractical Classes
BAUG2RYA-302GeneralPractical Classes
BAUG2MTM-322SpecialistTheoretical ClassesAs this class has number (2) In Theoretical Class and nbr (2) Practical class , its been repeated 4 times, in addition Class Type column is updated accordingly.
BAUG2MTM-322SpecialistTheoretical Classes
BAUG2MTM-322SpecialistPractical Classes
BAUG2MTM-322SpecialistPractical Classes


Any guidance and help would be highly appreciate it.

Thank you.


ASKER CERTIFIED SOLUTION
Avatar of T B
T B
Flag of Saudi Arabia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer