Forum Discussion

Elisa112's avatar
Elisa112
Helper V
1 year ago
Solved

Count Student Starts per month

Hello I need to count student starts per month, student passes in the same month and percentage of pass/fail each month  and visualise in a table.  I have a student table with columns student ID, s...
  • FarhanJeelani's avatar
    FarhanJeelani
    1 year ago

    Ji Elisa112 ,

    Your DAX expression is trying to evaluate a text value ('Jul 2024') as if it were a Boolean (True/False)—likely due to a line such as:

    Student[Status] = "Enrolled"

    being used outside of a filter function like FILTER() or CALCULATE(), or directly in a context where Power BI expects a Boolean expression.

     

    To Fix It:
    Please use CALCULATE to apply filters properly. Here's how to rewrite the measure correctly:

    Measure 1: Student Starts

    Student Starts =
    CALCULATE(
    DISTINCTCOUNT(Student[StudentID]),
    FILTER(
    Student,
    Student[Status] = "Enrolled"
    )
    )


    If you're grouping by 'Date'[MonthYear], make sure Date is the active date table and is properly related to Student[StartDate].

    You can add KEEPFILTERS('Date'[MonthYear]) if you're seeing issues with slicers not respecting the context.

     

    Optional: Add a helper column for clarity (if needed)
    If you're manually matching 'Jul 2024', it's better to create a MonthYear column like this in your Date table:

    MonthYear = FORMAT('Date'[Date], "MMM YYYY")


    Then use that column in your visual's axis or rows.

     

    Double-check:
    Student[StartDate] must be properly linked to Date[Date].

    You should not directly compare 'Jul 2024' to fields unless they're of the same type (Text vs Date).