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
raeesgillani
Advocate I
Advocate I

NETWORKDAYS inside PowerBI

There are two columns, Void Start and Due Date, I would like to work out the number of working days between the two days.

I've tried to use the following formula shown here (by @Greg_Deckler ), but I can't seem to get it to work.

This is the code for my situation (created it as a measure):

NetWorkDays = 
VAR Calendar1 = CALENDAR(MAX('Voids Data'[Void Start]),MAX('Voids Data'[Due Date (corrected)]))
VAR Calendar2 = ADDCOLUMNS(Calendar1,"WeekDay",WEEKDAY([Date],2))
RETURN COUNTX(FILTER(Calendar2,[WeekDay]<6),[Date])


It's accepted by PowerBI, but when I throw it into a table visualisation (this visualisation has two columns, one is void start date, the other is due date), I get the following error:



https://imgur.com/a/eCWRH4P
Please help.

1 ACCEPTED SOLUTION
raeesgillani
Advocate I
Advocate I

So I kept playing around with different solutions but the original solution provided by @Greg_Deckler seemed to work once I removed null values from my data and then made the extreme values zero:

VAR Calendar1 = CALENDAR(MIN('Voids Data'[Start]),MIN('Voids Data'[End]))
VAR Calendar2 = ADDCOLUMNS(Calendar1,"WeekDay",WEEKDAY([Date],2))
RETURN IF(COUNTX(FILTER(Calendar2,[WeekDay]<6),[Date])>1000,0,COUNTX(FILTER(Calendar2,[WeekDay]<6),[Date]))

View solution in original post

3 REPLIES 3
raeesgillani
Advocate I
Advocate I

So I kept playing around with different solutions but the original solution provided by @Greg_Deckler seemed to work once I removed null values from my data and then made the extreme values zero:

VAR Calendar1 = CALENDAR(MIN('Voids Data'[Start]),MIN('Voids Data'[End]))
VAR Calendar2 = ADDCOLUMNS(Calendar1,"WeekDay",WEEKDAY([Date],2))
RETURN IF(COUNTX(FILTER(Calendar2,[WeekDay]<6),[Date])>1000,0,COUNTX(FILTER(Calendar2,[WeekDay]<6),[Date]))

Hi raeesgillani,

Could you please tell us if your problem has been solved? If you have any problem, please feel free to tell me.

Best Regards,

Teige

Yes the issue was resolved, thank you for the check 🙂

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.