Forum Discussion
Counting with a date slicer
- 8 years ago
Hi Anonymous,
Create a Dimesion date table and then add the following measure:
Sick_Leave_Count = VAR start_date = MIN ( DimDate[Date] ) RETURN CALCULATE ( COUNT ( Absent[Worker] ); FILTER ( ALL ( Absent[Start Date]; Absent[End Date] ); Absent[Start Date] <= start_date && Absent[End Date] >= start_date ) ) + 0Regards,
MFelix
Thank you very much, it worked perfectly!
However, could you explain me how the "VAR"+"RETURN" work? I've never used those comands and I don't understand what they are doing here...
VAR start_date =
MIN ( DimDate[Date] )
RETURN
Hi Anonymous,
When you create calculated measures or columns you can setup difference variables (VAR) in order to simplify your measure, so when youn have a recurring calculation that you need to use several times in your measure you can create a variable or several, and use it instead of having to write the same code over and over again.
The Return part is the part where you define the start of your result calculation.
Check this link where you have an explanation of the use of variables in DAX.
Regards,
MFelix