Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
hollowshrine
Contributor
Contributor

Derive birthday and gender from string

Hi team 🙂 I'm working on my Master's thesis and I have a field that contains data for both the client's birthday and gender, formatted as such:

YYMMDD for male, e.g. 990101

YYMM+50DD for female, e.g. 995101

Does anyone know how to derive a column with just the date and a column with just the gender?

Any help would be immensely appreciated 🙂

1 Solution

Accepted Solutions
Vegar
MVP
MVP

Vegar_0-1597960262847.png

 


LOAD
  *,
  Date(alt (date#(birth_number, 'YYMMDD'),date#(birth_number-5000, 'YYMMDD')), 'YYMMDD') as CalculatedBirthday,
  IF(mid(birth_number,3,2)>12, 'female', 'male') as CalculatedGender
;
LOAD
  birth_number,

  birthday as ExpectedBirthday,
  gender as ExpectedGender
FROM example.xls (biff, embedded labels, header is 1 lines, table is Sheet1$);

 

View solution in original post

4 Replies
Taoufiq_Zarra

can you share a sample data and the expected output ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Vegar
MVP
MVP

Vegar_0-1597959424708.png

Try script like below:

 

 

LOAD 
   *,
   Dayname(alt(date#(GenderDate,'YYMMDD'),date#(GenderDate-5000,'YYMMDD'))) as BDay,
   IF(mid(GenderDate,3,2)>12, 'Female', 'Male') as Gender 
Inline [
GenderDate
990101
995101
991231
996231
];

 

 

See attached qvw

hollowshrine
Contributor
Contributor
Author

Sure 🙂 Attached in file.

Vegar
MVP
MVP

Vegar_0-1597960262847.png

 


LOAD
  *,
  Date(alt (date#(birth_number, 'YYMMDD'),date#(birth_number-5000, 'YYMMDD')), 'YYMMDD') as CalculatedBirthday,
  IF(mid(birth_number,3,2)>12, 'female', 'male') as CalculatedGender
;
LOAD
  birth_number,

  birthday as ExpectedBirthday,
  gender as ExpectedGender
FROM example.xls (biff, embedded labels, header is 1 lines, table is Sheet1$);