Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JamesFR06
Resolver IV
Resolver IV

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 !! 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@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" )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@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" )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.