cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sublog Helper I
Helper I

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 1
Community Support
Community Support

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

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.

 

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.

Helpful resources

Announcements
‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors