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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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