0

Distribute dates between two others days.

I have the fields Plan 1 to Plan 5 with the following milestones 10%,25%,70%,90% and 100% in the Plan 1 date field I have the start date 8/02/2024 and in the Plan 5 date field I have the date end 23/02/2024

I need to distribute the dates  for the Plan 2 Plan 3 and Plan4 fields depending on the % of the milestones automatic. The field Plan 2 Plan 3 and Plan 4 are fórmula field.

The other problems is no Holidays days, and no weekeeds. 

I have not been able to create the formula in Excel either. 😪

Too complicarte for me.

14 replies

null
    • Fred
    • 10 mths ago
    • Reported - view

    wow, that is a tricky ask. You would first need a table of holidays since Ninox has no way of knowing what holidays you follow. Then you would need to figure out how many days 25%, 70% and 90% is between the start date and end date. Then add those number of days to the start date, then check if it falls on a weekend then move the date out till it falls on a weekday then check if it falls on a holiday then move it out again till it falls on a weekday. Do you want the dates to always be on a particular day of the week (always on Mondays or always on Fridays)?

    Spain probably has multi-day holidays, so in your holiday table you will have a date field and number of day field, this can default to 1.

    I'll give it a shot but it could take awhile. I'm also trying to learn SwiftUI and that is hurting by brain. Now I know the difference between low code and 'real' code.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       

      Yes. Complicate I have the Holidays table, I Live In Spain but the projects is in Venezuela.

      Any day no problem the most important no weeked and holidays

      • Fred
      • 10 mths ago
      • Reported - view

      is there a pattern for your plan days? do you want always on a specific day of the week? Is 25% a week later than Plan 1? Is 90% a week before Plan 5?

      Give it think and let me know.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       

      The important thing is to Stay within the Start date and Finish Date, if I have a Document on two Weeks is possible two dates in the same week

    • red_kite
    • 10 mths ago
    • Reported - view

    Hi Raphael, try this script. I also didn't quite understand why it starts at 10%. In line 3 you have to add an array for holidays, or a reference to a holiday table. Mirko

    let all := days('Plan 1', 'Plan 5');
    let start := 'Plan 1';
    let holidays := [date(2024, 2, 6), date(2024, 2, 7)]; EXAMPLE
    let allworkdays := workdays('Plan 1', 'Plan 5');
    let result := for i in range(0, all) do
            let idx := date(year(start), month(start), day(start) + i);
            if weekday(idx) < 5 and not contains(holidays, idx) then
                text(date(year(start), month(start), day(start) + i))
            end
        end;
    let twentyfive := round(cnt(result) * 15 / 100);
    let seventy := round(cnt(result) * 60 / 100);
    let ninety := round(cnt(result) * 80 / 100);
    item(result, twentyfive) + " " + item(result, seventy) + " " + item(result, ninety)
    
      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       

      Hi The first 10% is when the 1er draft  is Release the 25% is the final internal draft the 70% is the first Issue to Client 90% the second Issue to Client and the 100% the approval by the Client.

      If I have a Document with a Budget 1200 € and win the first milestone 10% I Earned 120 €. When I complete the 100% win the 1.200 €.

      I will try it tonight. Thank Mirko

      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       In the EXAMPLE simple like select Holidays Table ?

      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       

      Hi the formula 6 is York script the dates give is ok, but need pace the first date on Plan 2 the second date on Plan 3 and the thirt date on Plan 4

      Thanks

    • red_kite
    • 10 mths ago
    • Reported - view

    Yes. holidays contains an array of dates, or selfemade select HolidaysTable.date.

    If 'Plan 2' an so on are fx-fields then split the last line of script.
    For 'Plan 2' 

    item(result, twentyfive);
    
    

    'Plan 3'

    item(result, seventy);

    and 'Plan 4'

    item(result, ninety);

    If you use button or trigger and fields are textfields then delete last line and take

    'Plan 2' := item(result, twentyfive);
    'Plan 3' := item(result, seventy);
    'Plan 4' := item(result, ninety)
    

    Mirko

      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       

      Thanks Mikro.

      Everything OK only Problem with the Holidays.

      That is the idea and works, only no take the Holidays days.

      https://youtu.be/ULUNhSvp5Wg?feature=shared

      let all := days('Plan 1', 'Plan 5');
      let start := 'Plan 1';
      let holidays := [date(2024, 2, 6), date(2024, 2, 7)];
      select Holidays;
      let allworkdays := workdays('Plan 1', 'Plan 5');
      let result := for i in range(0, all) do
              let idx := date(year(start), month(start), day(start) + i);
              if weekday(idx) < 5 and not contains(holidays, idx) then
                  text(date(year(start), month(start), day(start) + i))
              end
          end;
      let twentyfive := round(cnt(result) * 15 / 100);
      let seventy := round(cnt(result) * 60 / 100);
      let ninety := round(cnt(result) * 80 / 100);
      item(result, twentyfive)
      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       Ready Mikro, 👋 excelent, very good job Appreciate your time. 👍

      The script primary purpose is to filter workdays between two plans days, excluding weekends and specific holidays.

    • Rafael Sanchis
    • Rafael_Sanchis
    • 10 mths ago
    • Reported - view
    if 'Plan 5' <= DataDate and 'Plan 4' != 0 then
        'Mileston 5'
    else
        if 'Plan 4' <= DataDate and 'Plan 4' != 0 then
            'Milestone 4'
        else
            if 'Plan 3' <= DataDate and 'Plan 3' != 0 then
                'Milestone 3'
            else
                if 'Plan 2' <= DataDate and 'Plan 2' != 0 then
                    'Milestone 2'
                else
                    if 'Plan 1' <= DataDate and 'Plan 1' != 0 then
                        'Milestone 1'
                    end
                end
            end
        end
    end

     HI Mikro one problem here.

    The DataDate is 16/Feb/2024 the 'Plan 2'is 15/Feb/2024 is smaller than DataDate the field PV% the formula written above should be 25% no 10%. The Plan 2, Plan 3 and Plan are fórmula field.

    If the fields Plan2, plan3 Plan 4 are Date fields works perfect.

    There are any way to solve this.

      • red_kite
      • 10 mths ago
      • Reported - view

       I don't understand what you want. At the top you wrote that plan 2-4 should fit in between plan 1 and 5. It's too abstract and contradictory, as another date is now being added. In addition, English is not our mother tongue, so it may also be a misunderstanding on my part. Sorry. What is this supposed to look like mathematically if Plan 1 is earlier than DataDate? I can't understand the logic of your model. I guess I can't help here. Mirko

      • Rafael Sanchis
      • Rafael_Sanchis
      • 10 mths ago
      • Reported - view

       

      Nor worry Mirko,  I solve it. You helped me a lot 👍

Content aside

  • Status Answered
  • 10 mths agoLast active
  • 14Replies
  • 89Views
  • 3 Following