Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Find correct date record for DAX formula

Hello,

I am not sure how to do this in Power BI and was hoping for some help.

 

I have a formula that I use: 

HT - Target Hours = if( [Total Hours]<>0, ([HT - Days Worked] * 'Report Measures'[HT - # of Hours Per Day]) * [HT - % of Days])

Its pretty basic it calculates the targeted number of hours someone should work per month by # of Hours Per Day (calculated using the number of days in the date table) * % of Days worked (their FTE # of Days worked /5)
 
The problem is sometimes that changes and there is no set timeline when it changes the table below shows an example of how it shows up, is there a way to modify the above formula to check each month and use that # of hours per day for when there is a change? Some people could have no change since they started and some has 5 - 6 a year so is there a way to say find the time range in the start and end date below to get the $ of days worked?
 
Provider IDProvider NameProvider Start Date# of Days Worked Per Week% of Days WorkedMonthly Case TargetPeriod Case TargetYearly Case Targetprovider_target_idStart DateEnd Date
455104Jane Doe3-Aug-2030.625100300373216-May-22NULL
455104Jane Doe3-Aug-205141.67166.67500373117-Oct-2115-May-22

 

Here is my desired result: 

 # of Days Worked% of Days Worked# of Hours Per Day# of Days WorkedDesired Result
Jan30.63.3871312.0323
Feb30.63.75282.2500
Mar30.63.3871312.0323
Apr30.63.5302.1000
MayCombination   2.6878
1 - 1630.63.3871161.0489
19 - 31513.3871151.6389
June MTD513.5113.5000

 

2 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ;

    Sorry, I am confused. What is the calculation logic of the 2 columns marked in red?


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Yalan,

      Worked # of Hours is the target # of hours (105) divided by number of days in month so for Jan 105/31 = 3.3871. And Desired Result is % of Days worked * # of days in month so far/ total number of days in month * Worked # of Hours Per Day ie for Jan = .6 * 31/31 * 3.3871 = 2.323. The main thing is how do I get the formula to grab the correct % of Days Worked based on the above first table so 1 Jan - 16 May .6 then for May 17 - Current Day 1 that is based on the start and end dates in the first able.