Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sublog
Helper III
Helper III

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
v-xuding-msft
Community Support
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.

 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.