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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
roehler
Regular Visitor

NETWORKDAYS using Date VAR

I'm trying to generate a "WorkingDays" column that calculates the NETWORKDAYS using the StartDate/EndDate values I've created in my Quarter's table.  I'm not getting an error, but it's still not working:

 

WorkingDays =
    VAR StartDate = SELECTEDVALUE(Quarters[StartDate])
    VAR EndDate = SELECTEDVALUE(Quarters[EndDate])

    RETURN
    NETWORKDAYS(StartDate, EndDate,1,Holidays)

 

roehler_0-1747411913374.png

 

I've tried using SELECTEDVALUE(Quarters[StartDate].[Date] and SELECTEDVALUE(Quarters[EndDate].[Date], but I keep getting NULL in WorkingDays.  Any ideas?

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @roehler 

You don't need SELECTEDVALUE.

The calculated column expression is evaluated in the row context of the Quarters table, so you can reference columns of that table directly.

WorkingDays =
VAR StartDate = Quarters[StartDate]
VAR EndDate = Quarters[EndDate]
RETURN
    NETWORKDAYS ( StartDate, EndDate, 1, Holidays )

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

3 REPLIES 3
roehler
Regular Visitor

Thank you Owen, that was perfect.  I had added SELECTEDVALUE after my first attempt, and without it, it didn't work for some reason, but I removed it this morning and it worked fine.

rohit1991
Super User
Super User

Hi @roehler ,
The issue you're encountering—where the WorkingDays column returns null values despite not showing an error—is likely due to the misuse of the SELECTEDVALUE function within a calculated column context. SELECTEDVALUE is best suited for measures or visuals where there's a specific filter context.

 

In a calculated column, each row already has direct access to its respective values, so there's no need to use SELECTEDVALUE. Instead, you can refer directly to the [StartDate] and [EndDate] columns. Additionally, make sure that the Holidays table you're referencing is structured as a single-column table with proper date formatting. The corrected DAX should look like this:

WorkingDays = 
NETWORKDAYS(Quarters[StartDate], Quarters[EndDate], 1, Holidays[Date])

This version will calculate the working days for each row directly using the StartDate and EndDate values from the same row, along with your holiday list. Ensure the Holidays[Date] column contains valid date values and that the column is properly related to the date range you're analyzing.

 

Passionate about leveraging data analytics to drive strategic decision-making and foster business growth.

Connect with me on LinkedIn: Rohit Kumar.

OwenAuger
Super User
Super User

Hi @roehler 

You don't need SELECTEDVALUE.

The calculated column expression is evaluated in the row context of the Quarters table, so you can reference columns of that table directly.

WorkingDays =
VAR StartDate = Quarters[StartDate]
VAR EndDate = Quarters[EndDate]
RETURN
    NETWORKDAYS ( StartDate, EndDate, 1, Holidays )

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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