Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi folks,
I'm working in SQL Analysis Services, Live Connection.
My goal is to calculate the enrolment in a course, at various times through the semester. For example, at 1wk after start of course, midpoint of the course, and end of the course. However, the start and end dates change each year.
The data is organized as follows:
'StudentTimeTable' | |||
[StudentID] | [SchoolYear] | [StartDate] | [EndDate] |
As well, in a separate table in the model (but not incorporated in my measure below):
'SchoolSchedule' | |||
[SchoolYear] | [Semester] | [SemesterStartDate] | [SemesterEndDate] |
I have created this measure for 1wk after the start of the course which works (for past three years and involves manually coding the 1wk date), but I'm sure there is a better way to do this using variables and incorporating the SchoolSchedule table.
Course | Year | Semester Start Date | Enrolment@1wk |
ABC | 20182019 | 2/4/2019 | 22 |
ABC | 20192020 | 2/3/2020 | 27 |
DEF | 20182019 | 2/4/2019 | 24 |
DEF | 20202021 | 2/2/2021 | 18 |
XYZ | 20182019 | 2/4/2019 | 12 |
XYZ | 20192020 | 2/3/2020 | 25 |
XYZ | 20202021 | 2/2/2021 | 4 |
I'm still learning DAX and was hoping someone with more experience could show a better way to write the measure that makes use of the SchoolSchedule table, and allows for flexibility to work with all years and all SemesterStartDate and SemesterEndDates.
Thanks
Solved! Go to Solution.
Please supply good examples of your live data. The two first 'tables' are not very informative. Also, please show us the model. DAX can't be written in a vacuum.
Please supply good examples of your live data. The two first 'tables' are not very informative. Also, please show us the model. DAX can't be written in a vacuum.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |