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
ctedesco3307
Resolver II
Resolver II

Filter Non Working Days in a Date Range

Greetings Alll; 

I have a working measure that calculates the number of (working) hours between 2 date ranges but I need to filter out the non working days in the calculation 

 

The date range is in a table called Tempo Plans that shows the start date and end date of the Plan and the (working) hours per day  

ctedesco3307_0-1635786620708.png

 

The measue is in that same table, using the TDates calendar table to count the days in the plan and sumX a total hours for the plan 

 

Measure: 

Plan Hours =
SUMX(TempoPlans,
var currentStart = TempoPlans[START_DATE].[Date]
var currentEnd = TempoPlans[END_DATE].[Date]
return SUMX(FILTER( values( 'TDate'[Date]), 'TDate'[Date] >= currentStart && 'TDate'[Date] <= currentEnd), TempoPlans[Hours Per Day])
)
 
I need this measure to also filter out non working days. I have a Tworkday column set up in my TDate Table to flag if that Date is a working date or not - so I basically just need to add a filter to the measure to also include where Tworkday =1 to omit saturday, Sunday and holidays from the Plan Hours total. I'm not that expert in Power BI yet, so I don't  know how to update this mearure. Any and all help welcome.  Please let me know if you need more info.  Thank you  

 

ctedesco3307_1-1635787020164.png

 

 

 

1 ACCEPTED SOLUTION
ctedesco3307
Resolver II
Resolver II

ok-  actually solved my own problem and made a new column for the Plan Hours measure to reference - but if any one has a more sophisticated solution - please share - learning as I go here. Thx 

I replaced the TDate[Date] column references in Plan Hours with TDate[WorkingDay] - new column calc I added in my TDates table

WorkingDay = IF(OR(TDate[WeekDay]=1,TDate[WeekDay]=7),date(1900,1,1),IF(ISBLANK(TDate[THoliday]),TDate[Date],date(1900,1,1)))
 
ctedesco3307_0-1635788662941.png

 

View solution in original post

3 REPLIES 3
ctedesco3307
Resolver II
Resolver II

ok-  actually solved my own problem and made a new column for the Plan Hours measure to reference - but if any one has a more sophisticated solution - please share - learning as I go here. Thx 

I replaced the TDate[Date] column references in Plan Hours with TDate[WorkingDay] - new column calc I added in my TDates table

WorkingDay = IF(OR(TDate[WeekDay]=1,TDate[WeekDay]=7),date(1900,1,1),IF(ISBLANK(TDate[THoliday]),TDate[Date],date(1900,1,1)))
 
ctedesco3307_0-1635788662941.png

 

Greg_Deckler
Super User
Super User

@ctedesco3307 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler   Please find sample data and a screen shot of the calculation for the week 4/11 - 4/17.  Please let me know what add'l info you need. Thanks 

ctedesco3307_1-1635446931292.png

 

 

TEMPO_PLAN_IDDESCRIPTIONASSIGNEE_IDASSIGNEE_TYPECREATEDUPDATEDSTART_DATEEND_DATEIS_INCLUDE_NON_WORKING_DAYSITEM_IDITEM_TYPERECURRENCE_END_DATERECURRENCE_RULESECONDS_PER_DAYHours Per DayRoleID
1014 5fe25438f7ea2a0107281d28USER8/9/2021 17:258/16/2021 18:314/11/2021 0:004/17/2021 0:00FALSEUFF70UARPROJECT4/17/2021 0:00NEVER136803.8UFF70UAR5fe25438f7ea2a0107281d28

 

 

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.