Forum Discussion

JamesFR06's avatar
JamesFR06
Icon for Resolver IV rankResolver IV
2 years ago
Solved

Help on holdays calculation

Hi,

 

This is my table :

MatriculeBeg_DateEnding_DateReasonType AbsDab_AbsEnd_AbsDurationDur_rk
S2109508/02/202208/02/2022FORMATIONConsentie08/02/202210/02/20223Less 5 days
S2109509/02/202209/02/2022FORMATIONConsentie08/02/202210/02/20223Less 5 days
S2109510/02/202210/02/2022FORMATIONConsentie08/02/202210/02/20223Less 5 days
S2109505/04/202205/04/2022ABSENCE NON PAYEESubie05/04/202205/04/20221Less 5 days
S2109527/05/202227/05/2022CONGESConsentie27/05/202227/05/20221Less 5 days
S2109506/06/202206/06/2022CONGESConsentie06/06/202206/06/20221Less 5 days

 

My problem is due to the HR system sometimes for a Holiday period I can have many rows. I cannot do it on query !!

I would like to add these 4 columns in my table. SO  when there is only 1 line it is ok, more I do not succeed to achieve this.

The code should read each row and look at the difference between the previous End Abs row value and the beg value of the active row. And if difference is 1 it is the same period etc.....

ANy help would be very appreciate !! 

  • JamesFR06 So, perhaps something like this, although this would not be 100% foolproof:

    Dab_Abs Column = 
      VAR __Matricule = [Matricule]
      VAR __Reason = [Reason]
      VAR __TypeAbs = [Type Abs]
      VAR __Table = FILTER( 'Table', [Matricule] = __Matricule && [Reason] = __Reason && [Type Abs] = __TypeAbs)
      VAR __Resut = MINX( __Table, [Beg_Date] )
    RETURN
      __Result
    
    
    End_Abs Column = 
      VAR __Matricule = [Matricule]
      VAR __Reason = [Reason]
      VAR __TypeAbs = [Type Abs]
      VAR __Table = FILTER( 'Table', [Matricule] = __Matricule && [Reason] = __Reason && [Type Abs] = __TypeAbs)
      VAR __Resut = MAXX( __Table, [Ending_Date] )
    RETURN
      __Result
    
    
    Duration = ([End_Abs Column] - [Dab_Abs Column]) * 1.
    
    Dur_rk = IF( [Duration] < 5, "Less 5 days", "5 day or more" )

1 Reply

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

    JamesFR06 So, perhaps something like this, although this would not be 100% foolproof:

    Dab_Abs Column = 
      VAR __Matricule = [Matricule]
      VAR __Reason = [Reason]
      VAR __TypeAbs = [Type Abs]
      VAR __Table = FILTER( 'Table', [Matricule] = __Matricule && [Reason] = __Reason && [Type Abs] = __TypeAbs)
      VAR __Resut = MINX( __Table, [Beg_Date] )
    RETURN
      __Result
    
    
    End_Abs Column = 
      VAR __Matricule = [Matricule]
      VAR __Reason = [Reason]
      VAR __TypeAbs = [Type Abs]
      VAR __Table = FILTER( 'Table', [Matricule] = __Matricule && [Reason] = __Reason && [Type Abs] = __TypeAbs)
      VAR __Resut = MAXX( __Table, [Ending_Date] )
    RETURN
      __Result
    
    
    Duration = ([End_Abs Column] - [Dab_Abs Column]) * 1.
    
    Dur_rk = IF( [Duration] < 5, "Less 5 days", "5 day or more" )