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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
yaman123
Post Patron
Post Patron

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? 

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.