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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
JoshuaMartinezP
Regular Visitor

Calculate working days from multiple rows on the same date

Hi,

I am using the day name from a Date column to work out whether it is a 'Work Day' or not:

2 measures are as follows:

TS Day Name = FORMAT('Vessel Support Data'[Date], "dddd")
TS is work day = IF('Vessel Support Data'[TS Day Name] IN {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}, true, false)
 
I then want to use these measures to find the number of work days relevant to my dataset:

No. of Work Days =
CALCULATE(
    COUNTA('Vessel Support Data'[TS is work day]),
    'Vessel Support Data'[TS is work day] IN { TRUE },
    DISTINCT('Vessel Support Data'[Date])
)

However, my DISTINCT() function doesn't appear to work. For example I get 34 work days in Jan which corresponds with the total number of rows for Jan:
JoshuaMartinezP_0-1678961974725.png


Why does my 2nd filter not work? Is there an easier way to do this?

Thanks,
Josh

1 ACCEPTED SOLUTION

@JoshuaMartinezP Try this. PBIX is attached below signature.

No. of Work Days = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Table', [TS is work day] = TRUE),"Date",[Date])))

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

@JoshuaMartinezP Use NETWORKDAYS?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

Thanks for the fast reply. 

NETWORKDAYS requires me to specify holidays etc. It also gives me the total number of all 'work days' but I want only the work days that have been worked on, as indicated by my row data.

If I use the row data then I will only pull through the work days of the month that need to be counted. Which is why I am trying to use a CALCULATE filter.

Thanks,

@JoshuaMartinezP Holidays is optional. If you can post sample data as text I can take a look.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you, sample data as follows:

DateHoursTS Day NameTS is work day
03-Jan-233TuesdayTrue
03-Jan-230.5TuesdayTrue
03-Jan-234TuesdayTrue
04-Jan-233WednesdayTrue
04-Jan-234.5WednesdayTrue
05-Jan-234ThursdayTrue
05-Jan-232ThursdayTrue
05-Jan-232ThursdayTrue
06-Jan-234FridayTrue
06-Jan-234FridayTrue
09-Jan-233MondayTrue
09-Jan-231MondayTrue
09-Jan-233MondayTrue
10-Jan-233TuesdayTrue
10-Jan-232TuesdayTrue
10-Jan-231.5TuesdayTrue
10-Jan-233TuesdayTrue
11-Jan-233WednesdayTrue
11-Jan-234WednesdayTrue
11-Jan-230.25WednesdayTrue
12-Jan-232.5ThursdayTrue
13-Jan-232FridayTrue
13-Jan-233FridayTrue
16-Jan-233.5MondayTrue
16-Jan-234MondayTrue
17-Jan-231TuesdayTrue
17-Jan-236.5TuesdayTrue
18-Jan-235WednesdayTrue
18-Jan-232.5WednesdayTrue
19-Jan-230.5ThursdayTrue
19-Jan-233ThursdayTrue
19-Jan-234ThursdayTrue
20-Jan-233FridayTrue
20-Jan-234FridayTrue

@JoshuaMartinezP Wait a minute, is that third calculation a calculated column or a measure? Because if it is a calculated column generally does not work with measures because the calculated column only gets calculated at the time of data load.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

'No. of Work Days' is a measure. 
'TS Day Name' and 'TS is work day' are calculated columns, built from the 'Date' column.

My aim is to display the number in a card that updates when I make a selection in my slicers. At the moment, because of my 'Date Table', the number updates with the dates correctly:

JoshuaMartinezP_0-1678970229007.png

JoshuaMartinezP_1-1678970270929.png

But selecting a slicer from my main dataset doesn't effect the 'Date Table' results and therefore the number of working days stays unchanged.
That's why I need to have the measure base the working days on the dates in the dataset. Unfortunately there are multiple rows per working day and so I need to find a way to filter them in the calculation.

@JoshuaMartinezP Try this. PBIX is attached below signature.

No. of Work Days = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Table', [TS is work day] = TRUE),"Date",[Date])))

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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