Forum Discussion
Use variable dates in a measure
I need to create a measure with variable dates that I can change using a page-level filter.
Is there any way to this with PowerBI?
This is my measure:
CurrentStudentsOnly =
IF
(
(
// Admission before 10th Feb
SELECTEDVALUE('All Students'[Admission Date]) <= DATE(2024, 2, 10)
&&
// Not a guest student
NOT ISBLANK(SELECTEDVALUE('All Students'[Admission Date]))
)
||
(
// Guest student admitted before 10th Feb
SELECTEDVALUE('Guest Students'[Admission Date]) <= DATE(2024, 2,10)
&&
// Guest student withdrawal after 10th Jan
SELECTEDVALUE('Guest Students'[Withdrawal Date]) >= DATE(2024, 1, 10)
),
1,
0
)
I want the Date values to come from 2 page-level filters: startDate = DATE(2024,1,10) and endDate = DATE(2024,2,10).
I have also attached a Report file, please check it out for the implementation.
no need to reinvent the wheel. Your slicers/filters already can do the work for you.
Your data model is missing a calendar table to feed your slicers.
You should merge the Guest Students information into the All Students table, with a "Guest" flag.
1 Reply
- lbendlinSuper User
no need to reinvent the wheel. Your slicers/filters already can do the work for you.
Your data model is missing a calendar table to feed your slicers.
You should merge the Guest Students information into the All Students table, with a "Guest" flag.