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.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
44 | |
26 | |
22 | |
12 | |
8 |
User | Count |
---|---|
75 | |
51 | |
47 | |
16 | |
13 |