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
RJ_KON
Helper I
Helper I

Creating calculated column for working days

Hi guy's 

 

I am trying to create a calculated column with the number of working days in my table with two date columns From date and To date.

But in my date columns there are blanks and  I tried the below formulae, but it is giving me all zero values.

 

Below is my formulae

 

No. of working days =
VAR Startday =
SELECTEDVALUE ( 'Project Table'[From Date] )
VAR Endday =
SELECTEDVALUE ( 'Project Table'[To Date] )
VAR Daterange =
DATESBETWEEN ( 'Date'[Date].[Date], Startday, Endday )
VAR Dateworkdays =
NATURALLEFTOUTERJOIN ( Daterange, 'Date')
RETURN
IF (
Startday = BLANK (),
0,
IF ( Endday = BLANK (), 0, SUMX ( Dateworkdays, 'Date'[trueORfalse] ) )
)
 

My requirement is - 

I want to see if there is blank entry in my date columns, I want to see zero value in my workday column

 

I created a date table as shown in below figure.DateTable.JPG

Below is my project table

 

Project table.JPG

 

Any help will be wondefull.

 

Regards

Raj

2 REPLIES 2
VahidDM
Super User
Super User

Hi @RJ_KON 

 

Try this:

 

No. of working days =
VAR _S = 'Project Table'[From Date]
VAR _E = 'Project Table'[To Date]
RETURN
    CALCULATE (
        SUM ( Date[DayNumber_0_1] ),
        FILTER ( ALL ( Date ), Date[Date] >= _S && Date[Date] <= _E )
    )

 

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

Appreciate your Kudos!!



 

Hi Vahid, thanks for looking into my query. But I want the count of only weekdays.

 

Raj.

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.