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
tabuzahra
Helper II
Helper II

Showing Comulative Sum According To Slicer Dates

Hello,

I'm seeking your support in this impressive community in the following challenge that I'm facing,

 

I have created a measure to calculate the standard hours for each employee accoring to the dates selected in a slicer, but my challenge is

  1. The total standard hours for each employee is not correct as it should calculates the standard hours for each employee between the Hire date and Termination date. 
    1. The employee standard hours = (the correspondent standard hours for each date of the employee "working dates") - (the correspondendt standard hours for each date of the employee "Vacation Dates") .
    2. Taking into consideration that there is a date slicer and it should preview only the standard hours (Working Dates & Vacation Dates) between the specified filteres slicer dates.
  2. That the standard appears (BLANK) when I filter the slice between two dates.

 

below you can access the sample data. Sample Data

 

Explaination:

  1. Calendar Table
  2. HR Resources: It has all the hire & termination dates and I have expanded the dates between the hire & termination in the column (Working Dates) and (There is relationship between it and the Calendar table)
  3. HR Leaves: It has all the employees vacation and it contains the start and end dates for all the vacation periods. I have expanded the dates between the leave start and leave end dates in the column (Vacation Dates) and (There is a relationship between it and the HR Resources (Employee Name)). Also there is a inactive relationship between it and the calendar table (Vacation Dates & Calendar Date)

 

 

My measure that I have created is:

var Current_Employee=
MAX('HR Resources'[Employee Name])
var Hiring_Date =
CALCULATE (
MAX ( 'HR Resources'[Enterprise Hire Date] ),
FILTER ( 'HR Resources', 'HR Resources'[Employee Name] = Current_Employee ) )
var Termination_Date =
CALCULATE (
MAX ( 'HR Resources'[Termination Date]),
FILTER ( 'HR Resources', 'HR Resources'[Employee Name] = Current_Employee ) )
VAR Slicer_Start_Date =
CALCULATE (
MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
VAR Slicer_End_Date =
CALCULATE (
MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
RETURN
CALCULATE ( SUM ( 'Calendar'[Net Hours] ),
FILTER (
'Calendar',
'Calendar'[Date] >= Hiring_Date
&& Calendar[Date] <= Termination_Date
&& Calendar[Date] >= Slicer_Start_Date
&& Calendar[Date] <= Slicer_End_Date ) )
 
 
2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @tabuzahra ,

Could you tell me if your problem has been solved? If it is, kindly mark the helpful answer as a solution if you feel that makes sense. Welcome to share your own solution. More people will benefit from here.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-xuding-msft
Community Support
Community Support

Hi @tabuzahra,

You want to calculate cumulative net hours for the still working employees according to slicer dates . Right? The hours are between Termination Date and Enterprise Hire Date, and except vacation dates, weekends, holidays and Ramadan. Do I understand correctly?

Or we just need to calculate the hours between Termination Date and Enterprise Hire Date and expect vacation dates?

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.