Forum Discussion
DAX measure: Counting where index max value changes for each user
Hi, I am looking for a DAX measure that calculates current membership in a co-curricular organization based on max OrgIndex for each student. The problem is that I have one row for every org that the student was involved in by their year in college, so I may have multiple rows per student, and their max OrgIndex will be different depending on their involvement.
| STUDENT_ID | NAME | YEAR | LATEST_YEAR | TITLE | DESC | STATUS | OrgIndex |
| 123 | Student A | Y1 | TRACK TEAM - MEN | Sports | Active | 1 | |
| 123 | Student A | Y2 | CYCLING CLUB | Sports Clubs | Active | 2 | |
| 123 | Student A | Y3 | INTERVARSITY CHRISTIAN FELLOWS | Religious | Active | 5 | |
| 123 | Student A | Y4 | INTERVARSITY CHRISTIAN FELLOWS | Religious | Active | 6 | |
| 465 | Student B | Y1 | ACTUARIAL CLUB | Clubs | Active | 1 | |
| 465 | Student B | Y1 | FRISBEE CLUB | Sports Clubs | Active | 1 | |
| 555 | Student C | Y2 | Y3 | THETA XI | Social Fraternity | Pledge | 1 |
| 555 | Student C | Y2 | Y3 | RP CLUB | Clubs | 1 | |
| 555 | Student C | Y2 | Y3 | IEEE | Technical Society | 1 | |
| 555 | Student C | Y3 | Y3 | THETA XI | Social Fraternity | Active | 5 |
| 555 | Student C | Y3 | Y3 | RP CLUB | Clubs | 5 |
DAX measure that I tried, but it only does the max for the column, not for each student:
CountOrg = CALCULATE(
Calculated column I used to generate the OrgIndex.
Hi EduSurveys ,
Here we go. Courtesy of ImkeF She is amazing!
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
PBIX Heref
Counter = COUNTROWS ( FILTER ( SELECTCOLUMNS ( Surv, "ID", Surv[STUDENT_ID], "Org_Index", Surv[OrgIndex] ), VAR MAXOrgIndex = CALCULATE ( MAX ( Surv[OrgIndex] ), ALLEXCEPT ( Surv, Surv[STUDENT_ID] ) ) RETURN [Org_Index] = MAXOrgIndex ) )
12 Replies
- Nathaniel_C
Community Champion
Hi EduSurveys ,
Will you give us an example of your expected end product? You can dummy it up in Excel.
Thanks,
Nathaniel
- Nathaniel_C
Community Champion
Hi EduSurveys ,
So for Student A is this what you would expect to see "based on max OrgIndex for each student."
23 Student A Y4 INTERVARSITY CHRISTIAN FELLOWS Religious Active 6 - EduSurveys
Advocate II
So for CountOrg, I want it to count the # of students involved right now in orgs by DESC:
1 involved in Religious (Student A, OrgIndex=6), 2 in Clubs (Student B, OrgIndex=1; Student C, OrgIndex=5), 1 in Sports Clubs (Student B, OrgIndex=1), and 1 in Social Fraternity (Student C, OrgIndex=5). I only want the DAX measure to count membership where OrgIndex=Max for that student. Does that make sense?
Religious = 1
Clubs = 2
Sports Clubs =1
Social Fraternity = 1