Forum Discussion

electrobrit's avatar
electrobrit
Post Patron
3 years ago
Solved

work hours by week

I have a table with everyone's standard/available work hours by week
John 40

Dan 40

Sally 20

I have a seperate date table

I have a data table (with PTO by week etc-I am trying to get availability and other info but can't get the work hours by date)


I need to get it by dates (period end which is every saturday) Example
9/3/22 John 40
9/3/22 Dan 40
9/3/22 Sally 20
9/10/22 John 40
9/10/22 Dan 40
9/10/22 Sally 20
9/17/22 John 40
9/17/22 Dan 40
9/17/22 Sally 20
etc

sample pbix 

  • electrobrit , a new new table , Assume you table is "Table"

     

    generate(Table, filter(addcolumns(calendar(Date(2022,01,01), date(2022,12,31) ),

    "Week End date", , [Date]+ 7-1*WEEKDAY([Date],1)) , [Date] [Week end Date]) )

     

     

3 Replies

  • electrobrit , a new new table , Assume you table is "Table"

     

    generate(Table, filter(addcolumns(calendar(Date(2022,01,01), date(2022,12,31) ),

    "Week End date", , [Date]+ 7-1*WEEKDAY([Date],1)) , [Date] [Week end Date]) )

     

     

    • electrobrit's avatar
      electrobrit
      Post Patron

      I couldn't get that to work. I added a sample pbix, could you possibly see if you can get it to work there? Not sure how to change it up to work. Thank you in advance!


      pbix 

    • electrobrit's avatar
      electrobrit
      Post Patron

      I think I got it to work and do what I was wanting. With it being a new table I am not able to do a relationship to the main table. I'll try to work through that.
      Here is the corrected Dax:

      --AvailHours = generate(AvailableHours, filter(addcolumns(calendar(Date(2022,01,01), date(2022,12,31)), "Period End Date", [Date]+7-1*WEEKDAY([Date],1)), [Date]))