Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Naiane
Contributor
Contributor

Contagem de Admissão por Mês e Ano (Contabilizando aqueles que já foram desligados)

Olá pessoal! Tudo bem?

Sou nova no Qlik, gostaria de fazer a contagem de "admissão por mês" e "admissão por ano".

Porém o Qlik está me dando uma quantidade incorreta, ou seja, ele desconsidera os admitidos DESLIGADOS. Poderiam me ajudar? Obrigada!

Labels (1)
3 Replies
Qrishna
Master
Master

Sample data and output view pls, so we know what fields you have in your model and what your expectations are.

Naiane
Contributor
Contributor
Author

Set dataManagerTables = '','ODS_RH_CONTRATADOS','ODS_RH_CONTROLE_VAGAS';
//This block renames script tables from non generated section which conflict with the names of managed tables
 
For each name in $(dataManagerTables) 
    Let index = 0;
    Let currentName = name; 
    Let tableNumber = TableNumber(name); 
    Let matches = 0; 
    Do while not IsNull(tableNumber) or (index > 0 and matches > 0)
        index = index + 1; 
        currentName = name & '-' & index; 
        tableNumber = TableNumber(currentName) 
        matches = Match('$(currentName)', $(dataManagerTables));
    Loop 
    If index > 0 then 
            Rename Table '$(name)' to '$(currentName)'; 
    EndIf; 
Next; 
Set dataManagerTables = ;
 
 
Unqualify *;
 
__cityAliasesBase:
LOAD
Alias AS [__City],
geoKey AS [__geoKey],
CountryCode AS [__CityCountryCode]
FROM [lib://AttachedFiles/cityAliases.qvd]
(qvd);
 
__cityGeoBase:
LOAD
geoKey AS [__geoKey],
geoPoint AS [__GeoPoint]
FROM [lib://AttachedFiles/cityGeo.qvd]
(qvd);
 
__cityName2Key:
MAPPING LOAD
__City,
__geoKey
RESIDENT __cityAliasesBase;
 
__cityKey2GeoPoint:
MAPPING LOAD
__geoKey,
__GeoPoint
RESIDENT __cityGeoBase;
 
[ODS_RH_CONTRATADOS]:
LOAD
[MATRICULA] AS [MATRICULA-ID_VAGA],
[FUNCIONAL],
[NOME_COMPLETO],
[CPF],
Month([DT_ADMISSAO] ) AS MES_ADMISSAO,
    YEAR( [DT_ADMISSAO]) AS ANO_ADMISSAO,
    [DT_ADMISSAO],
[DT_NASCIMENTO],
    
IF(age(TODAY(), DT_NASCIMENTO)>=0 AND  age(TODAY(), DT_NASCIMENTO)<=18, 'Até 18 anos', 
IF(age(TODAY(), DT_NASCIMENTO)>=19 AND age(TODAY(), DT_NASCIMENTO)<=24, '19 a 24 anos', 
IF(age(TODAY(), DT_NASCIMENTO)>=25 AND age(TODAY(), DT_NASCIMENTO)<=29, '25 a 29 anos',
IF(age(TODAY(), DT_NASCIMENTO)>=30 AND age(TODAY(), DT_NASCIMENTO)<=45, '30 a 45 anos',
IF(age(TODAY(), DT_NASCIMENTO)>=46 AND age(TODAY(), DT_NASCIMENTO)<=59, '46 a 59 anos',
IF(age(TODAY(), DT_NASCIMENTO)>=60, '60 anos ou mais'
 
))))))
 
AS FAIXA_ETARIA_CRIADA,
    
[CARGO],
[SUPERIOR_HIERARQUICO],
[CENTRO_CUSTO],
[AREA_ATUACAO],
[VINCULO_EMPREGATORIO],
[SITUACAO_COLABORADOR], 
[DT_RESCISAO],
[COR],
[TIPO_DEFICIENCIA],
[GRAU_INSTRUCAO],
[CIDADE_RESIDENCIA],
[ESTADO_RESIDENCIA],
[MODALIDADE_CONTRATO],
APPLYMAP( '__cityKey2GeoPoint', APPLYMAP( '__cityName2Key', LOWER([CIDADE_RESIDENCIA])), '-') AS [ODS_RH_CONTRATADOS.CIDADE_RESIDENCIA_GeoInfo]
 FROM [lib://RH/ODS_RH_CONTRATADOS.qvd]
 
(qvd) where Match([SITUACAO_COLABORADOR],'Em Atividade Normal','Gozando Férias','Auxílio-Doença','Licença-Maternidade');
 
[ODS_RH_CONTROLE_VAGAS]:
LOAD
[ID_VAGA] AS [MATRICULA-ID_VAGA],
[STATUS],
[CONTRATACAO],
[TIPO_VAGA],
[SITUACAO],
[INICIO],
[DT_APROVACAO],
[DT_ADMISSAO] AS [ODS_RH_CONTROLE_VAGAS.DT_ADMISSAO],
[EFETIVIDADE],
[APROVEITAMENTO_INTERNO],
[FONTE_CONTRATACAO]
 FROM [lib://RH/ODS_RH_CONTROLE_VAGAS.qvd]
(qvd);
 
 
 
TAG FIELD [CIDADE_RESIDENCIA] WITH '$geoname', '$relates_ODS_RH_CONTRATADOS.CIDADE_RESIDENCIA_GeoInfo';
TAG FIELD [ODS_RH_CONTRATADOS.CIDADE_RESIDENCIA_GeoInfo] WITH '$geopoint', '$hidden', '$relates_CIDADE_RESIDENCIA';
 
DROP TABLES __cityAliasesBase, __cityGeoBase;
[autoCalendar]: 
  DECLARE FIELD DEFINITION Tagged ('$date')
FIELDS
  Dual(Year($1), YearStart($1)) AS [Year] Tagged ('$axis', '$year'),
  Dual('Q'&Num(Ceil(Num(Month($1))/3)),Num(Ceil(NUM(Month($1))/3),00)) AS [Quarter] Tagged ('$quarter', '$cyclic'),
  Dual(Year($1)&'-Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [YearQuarter] Tagged ('$yearquarter', '$qualified'),
  Dual('Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [_YearQuarter] Tagged ('$yearquarter', '$hidden', '$simplified'),
  Month($1) AS [Month] Tagged ('$month', '$cyclic'),
  Dual(Year($1)&'-'&Month($1), monthstart($1)) AS [YearMonth] Tagged ('$axis', '$yearmonth', '$qualified'),
  Dual(Month($1), monthstart($1)) AS [_YearMonth] Tagged ('$axis', '$yearmonth', '$simplified', '$hidden'),
  Dual('W'&Num(Week($1),00), Num(Week($1),00)) AS [Week] Tagged ('$weeknumber', '$cyclic'),
  Date(Floor($1)) AS [Date] Tagged ('$axis', '$date', '$qualified'),
  Date(Floor($1), 'D') AS [_Date] Tagged ('$axis', '$date', '$hidden', '$simplified'),
  If (DayNumberOfYear($1) <= DayNumberOfYear(Today()), 1, 0) AS [InYTD] ,
  Year(Today())-Year($1) AS [YearsAgo] ,
  If (DayNumberOfQuarter($1) <= DayNumberOfQuarter(Today()),1,0) AS [InQTD] ,
  4*Year(Today())+Ceil(Month(Today())/3)-4*Year($1)-Ceil(Month($1)/3) AS [QuartersAgo] ,
  Ceil(Month(Today())/3)-Ceil(Month($1)/3) AS [QuarterRelNo] ,
  If(Day($1)<=Day(Today()),1,0) AS [InMTD] ,
  12*Year(Today())+Month(Today())-12*Year($1)-Month($1) AS [MonthsAgo] ,
  Month(Today())-Month($1) AS [MonthRelNo] ,
  If(WeekDay($1)<=WeekDay(Today()),1,0) AS [InWTD] ,
  (WeekStart(Today())-WeekStart($1))/7 AS [WeeksAgo] ,
  Week(Today())-Week($1) AS [WeekRelNo] ;
 
DERIVE FIELDS FROM FIELDS [DT_RESCISAO], [INICIO] USING [autoCalendar] ;
 
LOAD
    MATRICULA,
    DT_RESCISAO
FROM [lib://RH/ODS_RH_CONTRATADOS.qvd]
(qvd);

 

diegozecchini
Creator III
Creator III

Hi!
to accurately count monthly and yearly admissions, including employees who have already been terminated, you can adjust your script to load all admissions data without filtering by the "SITUACAO_COLABORADOR" status. Below, I suggest modifying the script to ensure that it captures all admissions data, allowing you to apply filtering or adjustments within the Qlik app.


[ODS_RH_CONTRATADOS]:
LOAD
[MATRICULA] AS [MATRICULA-ID_VAGA],
[FUNCIONAL],
[NOME_COMPLETO],
[CPF],
Month([DT_ADMISSAO]) AS MES_ADMISSAO,
YEAR([DT_ADMISSAO]) AS ANO_ADMISSAO,
[DT_ADMISSAO],
[DT_NASCIMENTO],
IF(age(TODAY(), DT_NASCIMENTO)>=0 AND age(TODAY(), DT_NASCIMENTO)<=18, 'Up to 18 years',
IF(age(TODAY(), DT_NASCIMENTO)>=19 AND age(TODAY(), DT_NASCIMENTO)<=24, '19 to 24 years',
IF(age(TODAY(), DT_NASCIMENTO)>=25 AND age(TODAY(), DT_NASCIMENTO)<=29, '25 to 29 years',
IF(age(TODAY(), DT_NASCIMENTO)>=30 AND age(TODAY(), DT_NASCIMENTO)<=45, '30 to 45 years',
IF(age(TODAY(), DT_NASCIMENTO)>=46 AND age(TODAY(), DT_NASCIMENTO)<=59, '46 to 59 years',
IF(age(TODAY(), DT_NASCIMENTO)>=60, '60 years or more'
))))))
AS AGE_GROUP,
[CARGO],
[SUPERIOR_HIERARQUICO],
[CENTRO_CUSTO],
[AREA_ATUACAO],
[VINCULO_EMPREGATORIO],
[SITUACAO_COLABORADOR],
[DT_RESCISAO],
[COR],
[TIPO_DEFICIENCIA],
[GRAU_INSTRUCAO],
[CIDADE_RESIDENCIA],
[ESTADO_RESIDENCIA],
[MODALIDADE_CONTRATO],
APPLYMAP('__cityKey2GeoPoint', APPLYMAP('__cityName2Key', LOWER([CIDADE_RESIDENCIA])), '-') AS [ODS_RH_CONTRATADOS.CIDADE_RESIDENCIA_GeoInfo]
FROM [lib://RH/ODS_RH_CONTRATADOS.qvd] (qvd);

This adjustment removes the where Match([SITUACAO_COLABORADOR],'Em Atividade Normal','Gozando Férias','Auxílio-Doença','Licença-Maternidade') filter, ensuring that all records are loaded, including those with a terminated status. After loading this data, you can create charts or tables in Qlik with the following expressions to count admissions by month and year without excluding terminated employees:

Monthly admissions count: Count({<MES_ADMISSAO>} [MATRICULA-ID_VAGA])
Yearly admissions count: Count({<ANO_ADMISSAO>} [MATRICULA-ID_VAGA])

This approach ensures that all admitted employees, whether active or terminated, are included in the count.