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 August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Last month working MTD vs This month working MTD. HELP

Good Morning 

 

I am trying to compare a count of a column this month going off working days vs last month's working days.

 

I used the following community post to get the working day number next to the calendar dates so, for example, this month the 1st working day is the 1st and last month the 1st working day was the 2nd both have a 1 next to them.

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Same-working-day-last-month/m-p/2714230

 

I can get the counts to show vs the date field but I want this to show against a department without the date fields on the page.

Housden96_0-1675339318920.png

 

But instead, I would like it 

Housden96_1-1675339517699.png

 

I have joined the calendar table to my data table but I cannot figure out how to only to count the files opened between the first working day and the current working day.

 

Help would be appreciated 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solved it, if you need this add the following to your calendar table:

WorkdaySort =
VAR _sort =
CALCULATE (
COUNT ( 'Calendar'[Date] ),
FILTER (
'Calendar',
'Calendar'[Month] = EARLIER ( 'Calendar'[Month] )
&& 'Calendar'[Date] <= EARLIER ( 'Calendar'[Date] )
&& 'Calendar'[Year] = EARLIER( 'Calendar'[Year] )
&& NOT 'Calendar'[Day of Week] IN { 5, 6 }
)
)
VAR _result =
IF ( NOT 'Calendar'[Day of Week] IN { 5, 6 }, _sort )
RETURN
_result



Then the following as your measure:

Last Month MTD =
VAR _MINworkday_sort =
CALCULATE ( MIN( 'Calendar'[WorkdaySort] ), 'Calendar'[Date] = EOMONTH(TODAY(),0)+1 )
VAR _MAXworkday_sort =
CALCULATE ( MAX( 'Calendar'[WorkdaySort] ), 'Calendar'[Date] = TODAY() )
return
CALCULATE (
COUNT(Matters[cMatter]),
FILTER (
ALL('Calendar'),
'Calendar'[Year] = YEAR(TODAY())
&& 'Calendar'[Month] = MONTH(TODAY())-1
&& 'Calendar'[WorkdaySort] >= _MINworkday_sort
&& 'Calendar'[WorkdaySort] <= _MAXworkday_sort
)
)

 

Change the count to your measure or sum or count and it will pull in your last month-to-date working days aggregation. 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Solved it, if you need this add the following to your calendar table:

WorkdaySort =
VAR _sort =
CALCULATE (
COUNT ( 'Calendar'[Date] ),
FILTER (
'Calendar',
'Calendar'[Month] = EARLIER ( 'Calendar'[Month] )
&& 'Calendar'[Date] <= EARLIER ( 'Calendar'[Date] )
&& 'Calendar'[Year] = EARLIER( 'Calendar'[Year] )
&& NOT 'Calendar'[Day of Week] IN { 5, 6 }
)
)
VAR _result =
IF ( NOT 'Calendar'[Day of Week] IN { 5, 6 }, _sort )
RETURN
_result



Then the following as your measure:

Last Month MTD =
VAR _MINworkday_sort =
CALCULATE ( MIN( 'Calendar'[WorkdaySort] ), 'Calendar'[Date] = EOMONTH(TODAY(),0)+1 )
VAR _MAXworkday_sort =
CALCULATE ( MAX( 'Calendar'[WorkdaySort] ), 'Calendar'[Date] = TODAY() )
return
CALCULATE (
COUNT(Matters[cMatter]),
FILTER (
ALL('Calendar'),
'Calendar'[Year] = YEAR(TODAY())
&& 'Calendar'[Month] = MONTH(TODAY())-1
&& 'Calendar'[WorkdaySort] >= _MINworkday_sort
&& 'Calendar'[WorkdaySort] <= _MAXworkday_sort
)
)

 

Change the count to your measure or sum or count and it will pull in your last month-to-date working days aggregation. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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