cancel
Showing results for
Did you mean:
Frequent Visitor

Filter dataset based on rows belonging to all selected categories.

I am looking to do a Cohort analysis of students across multiple grades but the caveat being the students are the same in each grade.

For example, A class of 20 students graduates from Grade 1 to Grade 5 over 5 years. In this cohort, some students leave the class, and some new students join over the years.

I am struggling in finding score averages of students across 5 years of students who have attended all grades from 1 to 5.

Consider the following sample dataset

1,1,100

2,1,80

3,1,85

4,1,90

5,1,93

2,2,80

3,2,85

4,2,90

6,2,93 // New students joins, and student #5 leaves

2,3,80

3,3,85

4,3,90

6,3,93

7,3,87 // New student joins in grade 3

So my cohort should only consider student nos 1 through 4

while doing averages, count of students across grades etc.

2 REPLIES 2
Community Support Team

Re: Filter dataset based on rows belonging to all selected categories.

Hi @Deepak6642,

Based on my test, we can take the following steps to meet your requirement.

1. Enter the data and create a calculated table using the formula. Then create relationship between tables based on the student_id.

```Table =
DISTINCT (
UNION (
SELECTCOLUMNS ( '1', "new", '1'[student_id] ),
SELECTCOLUMNS ( '2', "new", '2'[student_id] ),
SELECTCOLUMNS ( '3', "new", '3'[student_id] )
)
)```

2. Create the measures as below. And create a table visual and make that filterd by Measure.

`Measure = IF(MAX('1'[grade]) = BLANK() || MAX('2'[grade])=BLANK() || MAX('3'[grade])= BLANK(), BLANK(),1)`
`ave 1 = SUMX(ALLSELECTED('1'),'1'[score])/[count]`
`ave 2 = SUMX(ALLSELECTED('2'),'2'[score])/[count]`
`ave 3 = SUMX(ALLSELECTED('3'),'3'[score])/[count]`
`count = CALCULATE(COUNT('Table'[new]),ALLSELECTED('Table'))`

For more details, please check the pbix as attached. If it doesn't meet your requirement, kindly share your excepted result to me.

https://www.dropbox.com/s/be9en7zernaeeyv/ilter%20dataset%20based%20on%20rows%20belonging%20to%20all...

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

Re: Filter dataset based on rows belonging to all selected categories.

Thank you for the attempt @v-frfei-msft.

However, this is not close to the expected result. The data for the various grades comes from a single table instead of different tables, as listed in the original message.

The dashboard must allow the user to choose a start and end grade, which ought to filter the results and present the same student cohort data as an aggregate.

The resultant graph/table must show the aggregate value across only the students which exist in all the grades from the chosen grade.

Above you can see the plot of aggregates of scores for a subject across the grades. The score aggregate is for students who are the same across all grades over the years. It excludes students who joined in or left in the middle for the selected grade/period.

Announcements

Back to School Contest

Engage and empower students with Power BI!

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 21 members 812 guests
Recent signins: