Kraig Helmeczi
07/10/2024, 11:52 PMcompany
, and each entry in company
has some number of employee
. I am creating a table that shows the most recently hired employee based on start date (which is attached to the employees table) for each company.
How can I do this? Metrics only allow for numerical values to be shown, but I want to show:
• Company Name
• Employee Name
• Employee Start DateMoises Morales
07/11/2024, 12:48 AMSELECT MAX(fact)
More details can be found here: MAX | GoodData Cloud. Please give this a try and let us know if it helps.Kraig Helmeczi
07/11/2024, 4:05 PMKraig Helmeczi
07/11/2024, 4:20 PMMoises Morales
07/11/2024, 8:34 PMMichal Hauzírek
07/11/2024, 9:08 PMSELECT COUNT({label/employee_id})
WHERE
(SELECT ROW_NUMBER(
(SELECT DATETIME_DIFF("2020-01-01",{label/hire_date.day}, DAY) BY {dataset/hires})
) DESC WITHIN ({label/company_id}) ) = 1
The row_number =1 condition ensures that you will always get only one record per company. Unfortunately this function does not work directly with dates, only numbers, so we are using a datetime_diff sub-metric here to convert date to a number of days since a fixed date. If I understood your data model correctly, if you use this metric in a visualization table with Company, Employee and Hire Date, it should give you for each company the last hired employee.
I hope this helps.Kraig Helmeczi
07/11/2024, 9:24 PM