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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NolanB
Frequent Visitor

Measure for work days per month based off job

Hello,

 

I have two tables; Jobs & Date Table

Jobs contains columns; Job, Start Date, End Date

Date Table contains columns; Date,Year&Month(text string with year and month of date),WorkDay?(True or false)

 

These tables are related by Jobs(Start Date) to Date Table(Date) in the type many to one

 

I want a matrix that shows Jobs(job) as columns and Date table(Year&month) as rows. I want my values to be the number of work days in each month for each job but every measure i have attempted for this has failed. Any help or advice would be appreciated!

 

Thanks, Nolan.

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@NolanB 
Here is the sample file with the solution https://www.dropbox.com/t/EjgpPwGXSmF36f4z

No need for relationship between the two tables.

The measure code is

Number of Day = 
VAR LastDateInFilter =
    MAX ( 'Date'[Date] )
VAR FirstDateInFilter = 
    MIN ( 'Date'[Date] )
VAR MinVisibleStartDate =
    MIN ( Job[Start Date] )
VAR MaxVisibleEndDate =
    MAX ( Job[End Date] )
VAR AvialableWrkingDays =
    CALCULATETABLE ( VALUES ( 'Date'[Date] ), 'Date'[IsWorkDay] = TRUE() )
VAR SatrtToEnd =
    CALENDAR ( MinVisibleStartDate, MaxVisibleEndDate )
VAR Result =
    COUNTROWS ( INTERSECT ( AvialableWrkingDays, SatrtToEnd ) )
RETURN
    Result

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

@NolanB 
Here is the sample file with the solution https://www.dropbox.com/t/EjgpPwGXSmF36f4z

No need for relationship between the two tables.

The measure code is

Number of Day = 
VAR LastDateInFilter =
    MAX ( 'Date'[Date] )
VAR FirstDateInFilter = 
    MIN ( 'Date'[Date] )
VAR MinVisibleStartDate =
    MIN ( Job[Start Date] )
VAR MaxVisibleEndDate =
    MAX ( Job[End Date] )
VAR AvialableWrkingDays =
    CALCULATETABLE ( VALUES ( 'Date'[Date] ), 'Date'[IsWorkDay] = TRUE() )
VAR SatrtToEnd =
    CALENDAR ( MinVisibleStartDate, MaxVisibleEndDate )
VAR Result =
    COUNTROWS ( INTERSECT ( AvialableWrkingDays, SatrtToEnd ) )
RETURN
    Result
tamerj1
Super User
Super User

Hi @NolanB 

Try

SUMX (

Job,

DATEDIFF ( Job[Start Date], Job[End Date], DAY )

)

Hi @tamerj1 

 

I appreciate your response,

But this only gives me the duration of each job, what i am looking for is the work days in each month for each job

 

Thanks,

@NolanB 

Can you please share a screen shot id your report and the results you got?

@tamerj1  I have used dummy data, as the original contains some confidential information, but the results are the same

 

I have included the two tables as well as the result

NolanB_0-1649180302340.png

NolanB_1-1649180342621.pngNolanB_2-1649180377615.png

 

NolanB
Frequent Visitor

NolanB_3-1649180838989.png

I have quickly constructed this to more clearly explain the matrix i wish to generate as a result. the numbers are not accurate just wanted to clarify

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.