I am building a model to allow reporting on two seperate datasets, for this example we'l say a Students dataset & a Staff dataset.
The datasets are pretty seperate and the only real link between the two is Date, so from a model perspective, there is a Students star schema & a Staff Star Schema.
The data displayed is snapshot type data, answering questions like: - For a selected date, show all active employees - for a selected date, show all enrolled students
This means that when a single date is selected, the model then finds all employees where the selected date falls within the employment start & end date , and finds all students where the selected date falls within the enrolled start & end date.
This means i had to make a decision, how to return the correct data from each schema with a single date dimension. Creating a relationship would not work as relationships in Tabular dont allow "between" type queries, so i instead have one unrelated Date Dimension and the Dax for each model finds applicable rows.
The problem is that its not the most performant. for perhaps 50k rows, adding a measure can take 5-10 seconds.
Im asking if there is a better way to either write the queries, or alter the model to still let me do "between" style queries but give better performance.
Below is an example of a dax query to return all students that were enrolled on a particular date.
Thanks for any advice.
All Enrolled Students:=IF (
HASONEVALUE ( 'Date'[Date] ),
CALCULATE (
DISTINCTCOUNT ( 'Students'[StudentID] ),
FILTER (
'Students',
'Students'[StudentStartDateID] <= MIN ( 'Date'[DateID] )
&& 'Students'[StudentEndDateID] >= MAX ( 'Date'[DateID] )
)
),
BLANK ())