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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Dnietota
New Member

Holidays in Period - Correct month

Hello everyone!

 

I have a dataset of holidays whith every employee petition as a row. In the dataset there are also two dates and the number of days between those dates.

  • Starting Date: The first day of the holidays
  • Ending Date: The last day of the holidays.

I would like to calculate the amount of holidays requested for each month but i'm facing some issues. Something similar to the manually collumn I worte below in "Comments" column.

  • If the start and end date are in the same month, I have no problems, all days correspond to the same month. 
  • If the start date month does not match the ending month, then I need to divide them and make the calculation correct. 
AbsenceEmployeeStarting DateEnding DateAmountComments
Holidays102329/05/202329/05/20231May
Holidays102329/05/202330/05/20232May
Holidays101229/05/202331/05/20233May
Holidays106529/05/202302/06/202353 days in May 2 in June
Holidays106529/05/202302/06/202353 days in May 2 in June
Holidays106131/05/202302/06/202331 day in May, 2 in June
Holidays100509/06/202309/06/20231June
Holidays104309/06/202309/06/20231June
Holidays100424/07/202328/07/20235July
Holidays100424/07/202328/07/20235July
Holidays101231/07/202331/07/20231July
Holidays101231/07/202304/08/202351 day in July, 4 in August
Holidays102331/07/202304/08/202351 day in July, 4 in August
Holidays104503/08/202304/08/20232August

 

Can someone please help me? I'm stucked with this... find attached the PBI file.

 

Regards,

2 REPLIES 2
ThxAlot
Super User
Super User

Generic solution

SPAN Detail.pbix

 

ThxAlot_0-1697312216783.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Ritaf1983
Super User
Super User

Hi @Dnietota 
unfortunately, there is no access to your file so I used a table that you attached.
You can achieve your goal with 2 calculated columns :
1. For delta between the days :

dated diff = DATEDIFF('Table'[Starting Date],'Table'[Ending Date],DAY)+1
2 for desired comments :
comments_ =
IF (
    DATEDIFF ( 'Table'[Starting Date], 'Table'[Ending Date], MONTH ) + 1 = 1,
    'Table'[Starting Date].[Month],
    DATEDIFF ( 'Table'[Starting Date], ENDOFMONTH ( 'Table'[Starting Date] ), DAY ) + 1 & " IN "
        & FORMAT ( 'Table'[Starting Date].[Date], "MMMM" ) & ", "
        & 'Table'[dated diff]
            - DATEDIFF ( 'Table'[Starting Date], ENDOFMONTH ( 'Table'[Starting Date] ), DAY ) - 1 & " IN "
        & FORMAT ( 'Table'[Ending Date].[Date], "MMMM" )
)
Ritaf1983_0-1697283018212.png

Link to pbix with the solution 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickl

 
Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.