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
LyonsBI_BRL
Helper III
Helper III

Calculating Number of Work Days per Row Per CandidateID

I'm attempting to calculate the number of work days per row for each candidateID

Right now I'm getting per row the total number for work days and number of workable hours. So instead of what I'm seeing below. 

 

LyonsBI_BRL_0-1636664954807.png

 

I'd rather see it more like this

LyonsBI_BRL_1-1636665125224.png

 

Currently how I'm getting an aggregate of the number of workable days and workable hours is through this code shown below.

How would I narrow it down so it's showing month by month?

Forecast Workable Days = 
VAR _MonthStart = DATE(YEAR(TODAY()), MONTH(TODAY()),1)
VAR _MonthEnd = EOMONTH ( _MonthStart , 12 )
VAR _dateBegin = [dateBegin]
VAR _dateEnd = [dateEnd]
VAR _StartDate = IF ( _dateBegin >= _MonthStart , _dateBegin , _MonthStart )
VAR _EndDate = IF ( _dateEnd <= _MonthEnd , _dateEnd , _MonthEnd )
VAR _NumberWorkDays = CALCULATE( COUNTROWS('Date'), DATESBETWEEN('Date'[Date], _StartDate, _EndDate), 'Date'[Weekday] = TRUE || 'Date'[Public Holidays] <> 0)

RETURN 

IF ( ISBLANK (_NumberWorkDays), 0, _NumberWorkDays)
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @LyonsBI_BRL ,

I created  a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a calculated column as below to get the working days per month:

 

Forecast Workable Days =
VAR _startdate =
    DATE ( YEAR ( 'Date'[Date] ), MONTH ( 'Date'[Date] ), 1 )
VAR _enddate =
    EOMONTH ( _startdate, 0 )
RETURN
    IF (
        'Date'[Date] >= _startdate
            && 'Date'[Date] <= _enddate
            && WEEKDAY ( 'Date'[Date], 2 ) <= 5
            && 'Date'[Public Holidays] = 0,
        1,
        0
    )

 

yingyinr_0-1636955496607.png

If the above one is not your expected result, please provide some sample data(exclude sensitive data) and your expected result with more details(calculation logic, special examples and visual settings etc.). Thank you.

Best Regards

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

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @LyonsBI_BRL ,

I created  a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a calculated column as below to get the working days per month:

 

Forecast Workable Days =
VAR _startdate =
    DATE ( YEAR ( 'Date'[Date] ), MONTH ( 'Date'[Date] ), 1 )
VAR _enddate =
    EOMONTH ( _startdate, 0 )
RETURN
    IF (
        'Date'[Date] >= _startdate
            && 'Date'[Date] <= _enddate
            && WEEKDAY ( 'Date'[Date], 2 ) <= 5
            && 'Date'[Public Holidays] = 0,
        1,
        0
    )

 

yingyinr_0-1636955496607.png

If the above one is not your expected result, please provide some sample data(exclude sensitive data) and your expected result with more details(calculation logic, special examples and visual settings etc.). Thank you.

Best Regards

Community Support Team _ Rena
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.