Forum Discussion

sublog's avatar
sublog
Helper III
7 years ago

Measure Working Days between dates, dynamic but with no relationship with calendar

Struggling with this, need some help. I have 2 tables, a headcount file and a calendar table. My calendar table only goes back to 1-1-2017. 

 

I have created a Dax measure that correctly calculates the number of working days between the start date of their employement and the current date. However, I need this to be dynamic when I filter for month or year. Presently, the filter does not affect the calculation. 

 

Been working on this one measure literally all day...

 

Here's my measure = 

Working Days since Start Date = IF([Total Working Days] < CALCULATE(Sum('Calendar'[Workingdays]),DATESBETWEEN('Calendar'[Date],'Headcount File'[Effective Job Date],TODAY())),[Total Working Days],CALCULATE(Sum('Calendar'[Workingdays]),DATESBETWEEN('Calendar'[Date],'Headcount File'[Effective Job Date],TODAY())))
 
Total Working Days is a measure in my calendar table = 
Total Working Days = SUM('Calendar'[Workingdays])
 
The goal was for me to take the lesser of the Total Working days in a period (or) the total working days of employment.
 



1 Reply

  • v-xuding-msft's avatar
    v-xuding-msft
    Community Support

    Hi sublog ,

    You could try to get the value of slicer using the SELECTEDVALUE function firstly. Then use the value as a date range.

    Table =
    VAR a =
    SELECTEDVALUE ( 'Calendar'[Date] )
    RETURN
    IF (
    ISFILTERED ( 'Calendar'[Date] ),
    IF (
    [Total Working Days]
    < CALCULATE (
    SUM ( 'Calendar'[Workingdays] ),
    DATESBETWEEN ( 'Calendar'[Date], a, TODAY () )
    ),
    [Total Working Days],
    CALCULATE (
    SUM ( 'Calendar'[Workingdays] ),
    DATESBETWEEN ( 'Calendar'[Date], a, TODAY () )
    )
    )
    )

    If you can upload a dummy file, we will help you as soon as possible. If you can't, can you please share some sample data?

     

    Best Regards,

    Xue Ding

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.