Forum Discussion
Previous value in a sequence
I have a dataset with the folllowing data points:
- unique Student ID (which student took the class)
- Class ID # (what class did they take)
- Sequence (what number course was this that they've taken from us 1=first course, 2=second course, 3=third course, etc.)
| Student ID | Class ID | Sequence |
| 1101 | 4433 | 1 |
| 1101 | 3377 | 2 |
| 1102 | 3221 | 1 |
| 1101 | 5698 | 3 |
| 1102 | 3222 | 2 |
What I want to know is if there were 100 students whose first class was Class ID 4433 (Class ID = 4433 AND Sequence = 1), what was the next class they took with us.
For example:
| Total # of Students with First Class ID 4433 |
| 100 |
| Total # of Students with Second Class ID 5589 | Total # of Students with Second Class ID 55890 | Total # of Students with Second Class ID 5591 | Total # of Students with Second Class ID 6778 |
| 50 | 10 | 25 | 15 |
I also want to see third classes and fourth etc. For each Class ID, I'd also like to see the average number of courses those student's go on to take.
7 Replies
- Ashish_MathurSuper User
Hi,
How does one interpret the last table? Please elaborate with a dataset which has more number of rows.
- erikriesenbergFrequent Visitor
Ashish,
Thanks for the reply. I see I didn't do a very good job explaining.
Maybe it will make more sense if I use more precise data.
Here's a sample of my data set:
Student ID Sequence Class 66724 1 AZ-300 Azure Architect Technologies 67194 1 CompTIA Cybersecurity Analyst Certification CySA+ (Exam CS0-001) 67194 2 CompTIA Cybersecurity Analyst (CySA+) Certification (Exam CS0-002) 68409 1 Excel 2016 - Part 2 68409 2 Excel 2016 - Part 3 69766 1 10982 Supporting and Troubleshooting Windows 10 69766 2 VMware Horizon® 7 - Install, Configure, Manage V7.7 70448 1 Excel 2016 - Part 2 70448 2 Outlook 2016 - Part 2 70448 3 PowerPoint 2016 - Part 2 72545 1 20341 Core Solutions of Microsoft Exchange Server 2013 72545 2 AWS Solutions Architect Certification - Associate 72545 3 AZ-103T00 - Microsoft Azure Administrator 72545 4 NCTA Cloud Architecture 72546 1 AWS Solutions Architect Certification - Associate 72546 2 NCTA Cloud Architecture 73633 1 Adobe Photoshop CC Part 1 (with Labs) 74258 1 Custom Course 75565 1 Office 365 Web Apps (with Skype for Business) 75565 2 Microsoft Teams 75565 3 SharePoint - Site Owner with Microsoft Forms and Flow (Modern Experience) 75565 4 55238 SharePoint Online for Administrators Student ID 66724 took one course and never returned to take another course. Student ID 68409 took Excel 2016 - Part 2 and then came back for Part 3 whereas Student ID 70448 also started with Excel 2016 - Part 2 first, but then took Outlook, and then Powerpoint. Both Student started with the same class, but took different subsequent classes.
What I want to be able to see is, for all of the students who took Excel 2016 - Part 2 as their first course:
1. How many took a second course?
2. What was the next course they took?
So if I have a total of 100 people that took Excel 2016 - Part 2 as their first course, how many went on to take Excel 2016 - Part 3, how many went on to take Outlook 2016, and so on.
Beyond that, if Excel 2016 - Part 2 was their first class, what was their third class, fourth class, etc. You can see that I have this data and can look at this sequence at the Student ID level, but I want to look at it at the class level. I want to see if there are certain classes are more likely to follow others based on students past enrollment behaviors.
- AnonymousNot applicable
Hi erikriesenberg ,
I created a sample pbix file(see attachment), please check whether that is what you want.
1. Create a class dimension table and use the class field of the table as slicer
2. Create the measures as below to get the count of students which filter the conditions
Tempcount = VAR _count = CALCULATE ( DISTINCTCOUNT ( 'Table'[Class] ), ALLEXCEPT ( 'Table', 'Table'[Student ID] ) ) VAR _tclass = CALCULATE ( MAX ( 'Table'[Class] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Student ID] ), 'Table'[Class] = SELECTEDVALUE ( 'Classes'[Class] ) ) ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Table'[Student ID] ), FILTER ( 'Table', _count > 1 && NOT ( ISBLANK ( _tclass ) ) ) )Count of students who take selected class = SUMX(VALUES('Table'[Student ID]),[Tempcount])If the above one is not your expected result, please provide more details(calculation logic, special examples and screenshot etc.) for it. Thank you.
Best Regards