Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Klabonty
Frequent Visitor

Calculate or SumX or what to add up courses for a student

Klabonty_0-1625759779193.png

The goal is to see if the student has dropped all their classes.  So in this case we would add up all the Add Courses (4 in this case) and subtract Drop Course (1 in this case) for a total of 3.  If the result is greater than zero the student still has classes and is considered active.  I need to do this for the entire table of course by student.

 

Need a DAX formula please (driving me crazy)

 

Thank you,

 

Kevin

1 ACCEPTED SOLUTION
daxer-almighty
Solution Sage
Solution Sage

It's doable in DAX but it should be calculated in PQ. I assume, of course, you're talking about a calculcated column, not a measure. But if you're talking about a measure, you still should create a column that will derive the status for each particular student id from the data in the table.

 

Here it is in DAX (but you really should do it in PQ):

[Student Active] = // calculated column
var CurrentStudentID = T[ID]
var NetEffect =
    sumx(
        FILTER(
            T,
            T[ID] = CurrentStudentID
        ),
        T[Add Course] - T[Drop Course]
     )
var Result = NetEffect > 0
return
    Result

View solution in original post

3 REPLIES 3
daxer-almighty
Solution Sage
Solution Sage

It's doable in DAX but it should be calculated in PQ. I assume, of course, you're talking about a calculcated column, not a measure. But if you're talking about a measure, you still should create a column that will derive the status for each particular student id from the data in the table.

 

Here it is in DAX (but you really should do it in PQ):

[Student Active] = // calculated column
var CurrentStudentID = T[ID]
var NetEffect =
    sumx(
        FILTER(
            T,
            T[ID] = CurrentStudentID
        ),
        T[Add Course] - T[Drop Course]
     )
var Result = NetEffect > 0
return
    Result

Your DAX code worked!  I now have added your column but now need to add up the students that have dropped all classes (abandoned).  In this sample data set  below if the student has abandoned I use your formula and get 1's in the student abandon column.  Now I want to count the students that abandoned. In this case one student abandoned and I have 4 abandon records for that student but I have a total of 3 students.  I keep getting sum's and calculations with the answer of 4 instead of 1 student.  Any help would be appreciated!

Klabonty_0-1626459076999.png

 

Thank you it worked!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.