Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

LOOPING?

Hi there, 

 

I have a data set similar to this:

Column "Hrs.per Day" shows the respective amount of hours assign per every scheduled day, starting the day "Planned Start".

I need to be able to assign each of those values to the respective date. So, my logic was to split the column "Hrs.per Day" in multiple columns each representing First, Secon, Thrid... day. Also, I need to be able to assign those hrs. to every day but only have Start and Finished dates, I expand the table with all the dates between those dates for each task.

 

End up with something like this, where the column "Assign Days" are the dates in between "Planned Start" and "Planned Finished Dates".

 

Now, I need to be able to build something that helps me to assign the value of the respective day to the date. For example:
IF  Assign Days  = Planned Start  
then Hrs.per Day.1 
IF  Assign Days  = (Planned Start +1)

then  Hrs.per Day.2 and so on.

IF  Assign Days  = (Planned Start +...N)

then  Hrs.per Day.N and so on.

 

I also need to consider that I don't know the max. amount of days that a project could have in the future and that some projects could last months, so and IF probably would not work by itself. I try to come up with a LOOP but I don't have the proper knowledge.

In the Power Query I come up with something like the follows, but again the list could be endless.

 

= Table.AddColumn(#"Renamed Columns", "Assign. Hours PD", each if [Planned Start] = [Between_Dates] then [Hrs.per.Day.1]
else if (Date.AddDays([Planned Start], 1)) = [Between_Dates] then [Hrs.per.Day.2]
else if (Date.AddDays([Planned Start], 2)) = [Between_Dates] then [Hrs.per.Day.3]
else if (Date.AddDays([Planned Start], 3)) = [Between_Dates] then [Hrs.per.Day.4]
else if (Date.AddDays([Planned Start], 4)) = [Between_Dates] then [Hrs.per.Day.5]
else if (Date.AddDays([Planned Start], 5)) = [Between_Dates] then [Hrs.per.Day.6]
else null)

Some help please!

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous 

     

    I made a guess on what you want, find hours per each date between Planned Start and End? file attached for your reference

     

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous 

     

    You can add a helper column to see the weekdays then filter out weekends, say I chose the Name of Day, then I can filter weekends out on the new column

     

     

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

     

    I made a guess on what you want, find hours per each date between Planned Start and End? file attached for your reference

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous ,

       

      Your solution was SIMPLY awesome... I haven't thought that something like that could be done. 
      You made MY DAY!
      Thanks for taking the time to help me here.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous ,

       

      I wonder if there's a chance to skip the weekends on the assignment of the hours. For example, in the table chart you provided the 8th and 9th are weekend days, but Item E runs along without skipping those days. There is a way in which the assign Hrs.per.Day skips those dates and resumes the 10th???  


      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

         

        You can add a helper column to see the weekdays then filter out weekends, say I chose the Name of Day, then I can filter weekends out on the new column