Forum Discussion

ctedesco3307's avatar
ctedesco3307
Icon for Resolver II rankResolver II
5 years ago
Solved

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  

 

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  

 

 

 

 

  • 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)))
     

     

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    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.

    • ctedesco3307's avatar
      ctedesco3307
      Icon for Resolver II rankResolver II

      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 

       

       

      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

       

       

  • 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)))