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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nik1
Employee
Employee

Calculate Student Journey

So I need to show student journey - find the number of student completed all the course in each month.
There are 2 tables.
1)  Courses details(Course master) Columns(ID, CourseName) 1-CourseA, 2-CourseB ...5-CourseE. 5 courses total. 

2) Transaction Table. Having details StudentId, CourseID, CompletedDate(DateTimeStamp) etc.

 

Lets say Student1 completed 2 courses(A and B) in May, 1 course(D) in June, 1 course(C) in July and 1 course(E) in Aug. Student Journey is completed in August.

 

Total student are 500, some will complete all 5 course in May, some in June etc.

 

Sample Data Screenshot for expected result

nik1_0-1659548456378.png

 


Any help is appreciated

2 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @nik1 
I have built my measure on top of @Jihwan_Kim's sample file. However, as per my understanding of your requirement I followed a completely different approach. https://www.dropbox.com/t/AMTGGmXFHZTBDa79

 

Count = 
VAR NumberOfCourses = COUNTROWS ( ALLSELECTED ( Course[CourseName] ) )
VAR CurrentDate = MAX ('Date'[Date] )
VAR Completed = 
    FILTER ( 
        ALL ( Data[StudentID] ), 
        VAR TableOnAndBefore = CALCULATETABLE ( Data,'Date'[Date] <= CurrentDate )
        VAR LastCompletedDate = MAXX ( TableOnAndBefore, Data[CompletedDate] )
        RETURN
            COUNTROWS ( TableOnAndBefore ) = NumberOfCourses 
                && MONTH ( CurrentDate ) = MONTH ( LastCompletedDate )
    )
RETURN
    COUNTROWS ( Completed )

 

 

View solution in original post

Hi @nik1 
Here is the updated file as requested https://www.dropbox.com/t/3IXKtCQpmt9MwReQ

Count = 
VAR CurrentMonth = MAX ( 'Date'[Year Month Number] )
VAR NumberOfCourses = COUNTROWS ( ALLSELECTED ( Course[CourseName] ) )
VAR CurrentDate = MAX ( 'Date'[Date] )
VAR T1 = FILTER ( All ( Data ), Data[CompletedDate] <= CurrentDate )
RETURN
    SUMX ( 
        ALL ( Data[StudentID] ),
        VAR Student = Data[StudentID]
        VAR T2 = FILTER ( T1, Data[StudentID] = Student )
        RETURN
            IF ( COUNTROWS ( T2 ) = NumberOfCourses, 1, 0 )
    )

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @nik1 
I have built my measure on top of @Jihwan_Kim's sample file. However, as per my understanding of your requirement I followed a completely different approach. https://www.dropbox.com/t/AMTGGmXFHZTBDa79

 

Count = 
VAR NumberOfCourses = COUNTROWS ( ALLSELECTED ( Course[CourseName] ) )
VAR CurrentDate = MAX ('Date'[Date] )
VAR Completed = 
    FILTER ( 
        ALL ( Data[StudentID] ), 
        VAR TableOnAndBefore = CALCULATETABLE ( Data,'Date'[Date] <= CurrentDate )
        VAR LastCompletedDate = MAXX ( TableOnAndBefore, Data[CompletedDate] )
        RETURN
            COUNTROWS ( TableOnAndBefore ) = NumberOfCourses 
                && MONTH ( CurrentDate ) = MONTH ( LastCompletedDate )
    )
RETURN
    COUNTROWS ( Completed )

 

 

Thanks you @tamerj1 the solution is working good. 

There is little more tweek required if you can help. We also need to show Cummulative total/Running total for each month.
Like in the solution file June 2022 has 1 count, July 2022 has 0 count but R.Total for July 2022 should be 1.
Example -> Current Month Count + previous month total

nik1_0-1659990558841.png

 

Hi @nik1 
Here is the updated file as requested https://www.dropbox.com/t/3IXKtCQpmt9MwReQ

Count = 
VAR CurrentMonth = MAX ( 'Date'[Year Month Number] )
VAR NumberOfCourses = COUNTROWS ( ALLSELECTED ( Course[CourseName] ) )
VAR CurrentDate = MAX ( 'Date'[Date] )
VAR T1 = FILTER ( All ( Data ), Data[CompletedDate] <= CurrentDate )
RETURN
    SUMX ( 
        ALL ( Data[StudentID] ),
        VAR Student = Data[StudentID]
        VAR T2 = FILTER ( T1, Data[StudentID] = Student )
        RETURN
            IF ( COUNTROWS ( T2 ) = NumberOfCourses, 1, 0 )
    )
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below. I hope the below can provide some ideas on how to create a solution for your dataset.

 

Untitled.png

 

All courses finish month: =
FORMAT (
    MAXX (
        GROUPBY (
            Data,
            Data[CompletedDate],
            "@lastcompleteddate", MAXX ( CURRENTGROUP (), Data[CompletedDate] )
        ),
        [@lastcompleteddate]
    ),
    "MMMM-YYYY"
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks @Jihwan_Kim  for replying and taking time to help here.
Update - I tried this solution as well, but results no as expected
Did not try you solution since it is not what the expected results  are.
I have update the post with sample data screenshot and expected results, if that can give more clarity.
Apprecaite your help

amitchandak
Super User
Super User

@nik1 , Assume total courses are 5

 

then

countx(filter( summarize(Table, Table[Student ID], "_1", calculate(distintcount(Table[CourseName])) ) , [_1] =5), [Student ID])

 

or

 

calculate(countx(filter( summarize(Table, Table[Student ID], "_1", calculate(distintcount(Table[CourseName])) ) , [_1] =5), [Student ID]), filter(Table, Table[Date] <= selectedvalue(Date[Date]) )

 

assuming the date is an independent date table

Thanks @amitchandak for replying and taking time to help here.
tried your suggestion but measure did not retun any results.
I have update the post with sample data screenshot and expected results, if that can give more clarity.
Apprecaite your help

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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