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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filtering Calculated 'Tenure' Measure Based on Filter selection and then Gouping it

Hi Team,

 

We are trying to  calculate Tenure for the active employees by giving a dynamic date input from the user . Active employees is a  measure named Headcount. The formula we are using  for calculating Tenure is :

Tenure = var _date=SELECTEDVALUE('calendar'[Date])-MAX('HC Snapshot'[orig_hire_dt])
return
IF(_date>0,_date/365.25,BLANK())
But using this condition we are getting tenure for all the employees(active and inactive).
The calendar table used here is not related to any of the base tables and is created on Power BI for selecting the date.
 
Please let us know the following things:
1)We need to filter Tenure with the active employee measure (Headcout).
2)We also need to calculate average for the Tenure
3)We have to create bins for average Tenure
 
 
 

 

which is multiple timestamp conditions validated against the date selected on the date slicer.

The formula we are using is

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Could you please share your sample data and excepted result to me if you don't have any Confidential Information.Please upload your files to One Drive and share the link here.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

 

Hi Frank

With this data we are applying the following records to get the active records. i.e

 Headcount = IF(SELECTEDVALUE('Calendar'[Date]),

CALCULATE (

[distinct_count],

FILTER (

'Sample_data',

'Sample_data'[working_strt_date_ts] < SELECTEDVALUE ( 'calendar'[Date] )

&& 'Sample_data'[working_end_date_ts] > SELECTEDVALUE ( 'calendar'[Date] )

&& 'Sample_data'[Org_date_strt_ts]< SELECTEDVALUE ( 'calendar'[Date] )

&& 'Sample_data'[Org_date_end_ts]> SELECTEDVALUE ( 'calendar'[Date] )

  ) , 0 )
 
 
  Here 1)[distinct_count] = DISTINCTCOUNT('Sample_data'[employee_id])
             2)Calendar Date = This we have created manually on Power BI to have unique calendar table and this is where the user is giving the date input so as to make the dashboard point in time
  
  
  Our Requirement :
  
  1) We want Point in time Tenure and Point in time avg tenure

                 Tenure Required Formula -  (Calendar_date - Hire_Date)/365.25 --> Here Calendar_date  is selected by  user

                 The Dax created for the same  -  

                       Tenure = var _date=SELECTEDVALUE('calendar'[Date])-MAX('Sample_data'[hire_dt])
                                                    return
                                                    IF(_date>0,_date/365.25,BLANK())

        2) We want to create Bins for the Tenure and show it against the Planning_org in a Heat map

                  For Example - 
      
                    (i)1 to 2 Years   for Tenure less than 1
                    (ii)2 to 3 Years    For Tenure greater than 1 and less than 2  


 Note : We do not have a unique date column in our data hence we have created the Calendar Table on Power BI

 

 

Sample_Data

 

Employee_IdPlanning_OrgPlanning_sub_orgHire_Dtworking_strt_date_tsworking_date_end_tsOrg_date_strt_tsOrg_date_end_ts
101129SalesSales_engineer07/02/79 0:0009/25/2017 18:0212/31/9999 23:5906/11/2018 18:0512/31/9999 23:59
101130MarketingMarketing_engineer07/15/85 0:0006/02/2018 18:0212/31/9999 23:5906/11/2018 18:0512/31/9999 23:59
101130MarketingMarketing_CS07/15/85 0:0009/25/2017 6:0206/02/2018 18:0206/11/2018 18:0512/31/9999 23:59
101131PRPR_engineer10/05/92 0:0012/18/2018 6:0212/31/9999 23:5912/18/2018 18:0412/31/9999 23:59
101131PRPR_CS10/05/92 0:0009/10/2017 6:0412/18/2018 6:0209/10/2018 18:0412/18/2018 18:04
101131PRPR_R&D10/05/92 0:0006/11/2017 18:0509/10/2017 6:0406/11/2018 18:0509/10/2018 18:04
101132OperationsOperations_engineer03/02/81 0:0012/06/2018 23:5912/31/9999 23:5912/31/2018 6:0512/31/9999 11:59
101132OperationsOperations_CS03/02/81 0:0006/06/2017 18:0512/06/2018 23:5906/11/2018 18:0512/31/2018 6:05

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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