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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
yaman123
Post Partisan
Post Partisan

HR Query Help - headcount by function

Hi, 

 

I am creating a report for our HR Dept and i am having issues with a query i would like to display in a graph format. 

 

I have the below dataset i have created in Oracle SQL. You can see if there is a change to either the costctr, site or grade, the valid from and valid to dates are changed and a new line is added for each change.  E.g Employee A or Employee G

 

I would like to write a case statement to show what function each employee is in e.g if costctr value is 145 and site is not A then function 'central' etc. But because the report will be run by choosing a month from a date table, how would i write this so the correct data is displayed per month and each employee will display the correct function? 

 

Any help would be greatly appreciated! 

 

EMP_NOINTERNAL_DISPLAY_NAMEDATE_OF_EMPLOYMENTDATE_OF_LEAVINGPROPERTY_CODE1COSTCTR_VALUECOSTCTR_FROMCOSTCTR_TOPROPERTY_CODE2SITE_VALUESITE_FROMSITE_TOPROPERTY_CODE3GRADE_VALUEGRADE_FROMGRADE_TO
300520Employee A01/10/200012/31/9999COSTCTR27003/09/201931/12/9999SITEA03/09/201931/12/9999GRADEL503/09/201931/03/2020
300520Employee A01/10/200012/31/9999COSTCTR27003/09/201931/12/9999SITEA03/09/201931/12/9999GRADEL401/04/202031/12/9999
500264Employee B14/02/199512/31/9999COSTCTR10103/09/201931/12/9999SITEB03/09/201931/12/9999GRADE303/09/201931/12/9999
500265Employee C18/08/200812/31/9999COSTCTR14503/09/201931/12/9999SITEC03/09/201931/12/9999GRADEL6a03/09/201931/12/9999
500267Employee D27/05/200812/31/9999COSTCTR14503/09/201931/12/9999SITEC03/09/201931/12/9999GRADEL603/09/201931/12/9999
500316Employee E19/07/201012/31/9999COSTCTR14503/09/201931/12/9999SITEB03/09/201931/12/9999GRADE103/09/201905/01/2020
500316Employee E19/07/201012/31/9999COSTCTR14503/09/201931/12/9999SITEB03/09/201931/12/9999GRADEL6a06/01/202031/12/9999
500317Employee F06/04/200912/31/9999COSTCTR10103/09/201931/12/9999SITEB03/09/201931/12/9999GRADEL603/09/201931/12/9999
510173Employee G28/02/201812/31/9999COSTCTR10103/09/201931/12/9999SITEC103/09/201902/08/2020GRADE403/09/201902/08/2020
510173Employee G28/02/201812/31/9999COSTCTR10103/09/201931/12/9999SITEC03/08/202031/12/9999GRADE403/09/201902/08/2020
510173Employee G28/02/201812/31/9999COSTCTR10103/09/201931/12/9999SITEC103/09/201902/08/2020GRADEL6a03/08/202031/12/9999
510173Employee G28/02/201812/31/9999COSTCTR10103/09/201931/12/9999SITEC03/08/202031/12/9999GRADEL6a03/08/202031/12/9999
4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @amitchandak ,

 

Please show me your expected output table.

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Create the function column in the table. I think that would be the fastest in terms of query speed.

What also would be convenient is having a seqnr in your table (each row a unique number)

 

Next you need to know how tou want the report to act.

Do you want to report per day ? Or want to report per month ? So if the user selects a month he/she get the value which is valid on the first or last day of the month

 

If you know what you want you can create a table which stores:

Calender date - SeqNr

 

Now if you have the requirement of reporting daily you link your calender on calenderdate

if on last day of month you add a column to each calendar date with lastday and link on lastdayofmonth etc

 

Hi Remyo, 

 

Thanks for getting back to my query. 

 

The report will be run monthly, so the last date of the month will be used. 

 

In terms of creating a function column, is this created in SQL or Power BI? 

 

How would i add seq numbers to a table? How would this work with the date selection? 

 

 

amitchandak
Super User
Super User

@yaman123 , refer if this blog can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.