Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I work for a university and have been tasked with improving an enrollment dashboard.
The previous analyst set up a query with millions of rows that essentially loads a row for each student for each day that they were enrolled. The query takes entirely too long to refresh and taxes the server.
I've created a dataset that contains one row per student. For now I've reduced the data to a single term, but ultimately it will contain one row per term per student.
I'd like to generate a running total that also accounts for students that drop all of their courses. Ultimatley, I'd like to use DayMark as the X-Axis, this represents the day's away from the start of the term. This will also allow me to visualize across terms relatively easily. For testing purposes I've been focused on using the date columns.
I was able to generate a rolling total using this code:
I've been unable to modify the code to account for my [Last_Date] variable.
I currently have an active 1 to many relationship with my [First_Date] variable. I also have an inactive 1 to many relationship with my [Last_Date] variable.
I spent some time messing around with USERELATIONSHIP, but couldn't ultimatley produce anything useful.
This is the code I've tried that doesn't produce the result I'm looking for:
The other issue I'm having, is that I'd like to generate a value for each date, even if there is no movement from the previous date. My code seems to only generate data points for dates during which enrollment changed.
Solved! Go to Solution.
Hi @j89k,
I hope you are doing well today 😄❤️
So the problem is that you need to count students who were enrolled on each date which means students whose First_Date is on or before the current date AND whose Last_Date is on or after the current date (or null if still enrolled)
Here is some solutions that should work for you:
First Approach : Active Enrollment Count (I recommend you this)
Active_Enrollment_Count =
VAR CurrentDate = SELECTEDVALUE('Calendar'[Calendar_Date])
RETURN
CALCULATE(
COUNTROWS('Spring2025'),
FILTER(
ALL('Spring2025'),
'Spring2025'[First_Date] <= CurrentDate &&
(ISBLANK('Spring2025'[Last_Date]) || 'Spring2025'[Last_Date] >= CurrentDate)
)
)
Second Approach : Using Both Relationships
Active_Enrollment_Count_v2 =
VAR CurrentDate = SELECTEDVALUE('Calendar'[Calendar_Date])
RETURN
CALCULATE(
COUNTROWS('Spring2025'),
USERELATIONSHIP('Calendar'[Calendar_Date], 'Spring2025'[First_Date]),
'Spring2025'[First_Date] <= CurrentDate
) -
CALCULATE(
COUNTROWS('Spring2025'),
USERELATIONSHIP('Calendar'[Calendar_Date], 'Spring2025'[Last_Date]),
'Spring2025'[Last_Date] < CurrentDate
)
Third Approach : Comprehensive with DayMark
Since you mentioned wanting to use DayMark as your X-axis:
Active_Enrollment_By_DayMark =
VAR CurrentDayMark = SELECTEDVALUE('Calendar'[DayMark_Value]) // You will need to create this in your Calendar table
VAR TermStartDate = DATE(2024, 11, 6) // Or get this from your term table
VAR CurrentDate = TermStartDate + CurrentDayMark
RETURN
CALCULATE(
COUNTROWS('Spring2025'),
FILTER(
ALL('Spring2025'),
'Spring2025'[First_Date] <= CurrentDate &&
(ISBLANK('Spring2025'[Last_Date]) || 'Spring2025'[Last_Date] >= CurrentDate)
)
)
To Fix Your Calendar Table Issue:
Calendar =
VAR StartDate = DATE(2024, 11, 1) // Adjust based on your needs
VAR EndDate = DATE(2025, 5, 31) // Adjust based on your needs
RETURN
ADDCOLUMNS(
CALENDAR(StartDate, EndDate),
"DayMark_Value", DATEDIFF(DATE(2024, 11, 6), [Date], DAY) // Relative to term start
)
So why Your Current Approach Does not Work?
Some Tips For you...
Create a complete Calendar table with all dates
Remove active relationships to Spring2025 (or keep them inactive)
Use the measures above that explicitly handle both First_Date and Last_Date
Hi @j89k ,
Can you create a column to see if student has dropped using below column for dax.
Dropped = IF([Last_Date] < [Term_End_Date], 1, 0)The use it to filter your countrows measure?
Thanks and Regards,
Praful
Hi @j89k,
I hope you are doing well today 😄❤️
So the problem is that you need to count students who were enrolled on each date which means students whose First_Date is on or before the current date AND whose Last_Date is on or after the current date (or null if still enrolled)
Here is some solutions that should work for you:
First Approach : Active Enrollment Count (I recommend you this)
Active_Enrollment_Count =
VAR CurrentDate = SELECTEDVALUE('Calendar'[Calendar_Date])
RETURN
CALCULATE(
COUNTROWS('Spring2025'),
FILTER(
ALL('Spring2025'),
'Spring2025'[First_Date] <= CurrentDate &&
(ISBLANK('Spring2025'[Last_Date]) || 'Spring2025'[Last_Date] >= CurrentDate)
)
)
Second Approach : Using Both Relationships
Active_Enrollment_Count_v2 =
VAR CurrentDate = SELECTEDVALUE('Calendar'[Calendar_Date])
RETURN
CALCULATE(
COUNTROWS('Spring2025'),
USERELATIONSHIP('Calendar'[Calendar_Date], 'Spring2025'[First_Date]),
'Spring2025'[First_Date] <= CurrentDate
) -
CALCULATE(
COUNTROWS('Spring2025'),
USERELATIONSHIP('Calendar'[Calendar_Date], 'Spring2025'[Last_Date]),
'Spring2025'[Last_Date] < CurrentDate
)
Third Approach : Comprehensive with DayMark
Since you mentioned wanting to use DayMark as your X-axis:
Active_Enrollment_By_DayMark =
VAR CurrentDayMark = SELECTEDVALUE('Calendar'[DayMark_Value]) // You will need to create this in your Calendar table
VAR TermStartDate = DATE(2024, 11, 6) // Or get this from your term table
VAR CurrentDate = TermStartDate + CurrentDayMark
RETURN
CALCULATE(
COUNTROWS('Spring2025'),
FILTER(
ALL('Spring2025'),
'Spring2025'[First_Date] <= CurrentDate &&
(ISBLANK('Spring2025'[Last_Date]) || 'Spring2025'[Last_Date] >= CurrentDate)
)
)
To Fix Your Calendar Table Issue:
Calendar =
VAR StartDate = DATE(2024, 11, 1) // Adjust based on your needs
VAR EndDate = DATE(2025, 5, 31) // Adjust based on your needs
RETURN
ADDCOLUMNS(
CALENDAR(StartDate, EndDate),
"DayMark_Value", DATEDIFF(DATE(2024, 11, 6), [Date], DAY) // Relative to term start
)
So why Your Current Approach Does not Work?
Some Tips For you...
Create a complete Calendar table with all dates
Remove active relationships to Spring2025 (or keep them inactive)
Use the measures above that explicitly handle both First_Date and Last_Date
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 9 | |
| 9 | |
| 8 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 23 | |
| 18 | |
| 16 | |
| 15 | |
| 14 |