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

Date Function

Hello,

I am working with a data set that consists of two tables:

1) [المسنين]

2) [المتدربات و مقدمي الرعاية ]:

Here is the script for the two tables (Qlik sense desktop):

[المسنين]:

LOAD

  [م/Internal ID] AS [المسنين.م/Internal ID],

  [National Identity Number of Patient/رقم قومي المريض],

  [اسم المريض/Patient Name],

  [Gender/الجنس] AS [المسنين.Gender/الجنس],

  [Age/السن],

  [تاريخ الميلاد/Date of Birth] AS [المسنين.تاريخ الميلاد/Date of Birth],

  [الوزن( كجم)/Weight (KG)],

  [الاجازة/Leave],

  [العنوان/Address] AS [المسنين.العنوان/Address],

  [عنوان آخر/Other Address],

  [تليفون/Telephone],

  [المتواجدون بالمنزل/Present in Client's Residence],

  [درجة القرابة/Relation],

  [اسم المسؤل عن المريض/Name Custodian of],

  [درجة قرابة المسؤول بالمريض/Relation of Custodian to Patient],

  [موبايل المسؤول/Custodian Mobile],

  [رقم أرضي المسؤول/Custodian Land Line],

  [رقم مكتب  المسؤول/Custodian Office Number],

  [العنوان/Custodian Address],

  [الأيميل/Email of Custodian],

  [أفضل وقت للأتصال ( من : الي )/Best Time to Contact Custodian],

  [جواز السفر/رقم قومي المسؤول/National Identity/Passport  Number of Custodian],

  [Date of Issue],

  [وظيفة المسؤول /Occupation of Custodian],

  [جهة عمل المسؤول /Employer of Custodian],

  [Start Date/تاريخ البدء] AS [المسنين.Start Date/تاريخ البدء],

  [End Date/تاريخ الانتهاء] AS [المسنين.End Date/تاريخ الانتهاء],

  [الفرع/Branch] AS [المسنين.الفرع/Branch],

  [District/حي] AS [المسنين.District/حي],

  [Type/النوع] AS [المسنين.Type/النوع],

  [نسبة رضا/Satisfaction Rate],

  [ساعات الرعاية/Hours of Care],

  [اسم المقدم رعاية /Name of Caregiver] AS [اسم-Name],

  [دخل معا من أجلك /TFY Income]

FROM [lib://TFY/TFY For Qlik Master Sheet FINAL Copy.xlsx]

(ooxml, embedded labels, table is المسنين);

[المتدربات و مقدمي الرعاية ]:

CROSSTABLE ([Date/التاريخ],[Salary/الراتب],27)

LOAD

  [اسم-Name],

  [المتدربات و مقدمي الرعاية .Type/النوع],

  [المتدربات و مقدمي الرعاية .الفرع/Branch],

  [Gender/ الجنس],

  [المتدربات و مقدمي الرعاية .تاريخ الميلاد/Date of Birth],

  [المتدربات و مقدمي الرعاية .العنوان/Address],

  [المتدربات و مقدمي الرعاية .District/حي],

  [المتدربات و مقدمي الرعاية .موبايل/Mobile number],

  [المتدربات و مقدمي الرعاية .تليفون آخر/Other Telephone],

  [الحاله الأجتماعيه/Marital Status],

  [الموقف من التجنيد/Conscription Status],

  [الأمراض المزمنه/Chronic Illness],

  [المتدربات و مقدمي الرعاية .Education/مستوى التعليم],

  [المتدربات و مقدمي الرعاية .Specialisation/التخصص],

  [المتدربات و مقدمي الرعاية .سنة التخرج/Graduation Date],

  [المتدربات و مقدمي الرعاية .الوظيفه السابقه/Past Occupation],

  [المتدربات و مقدمي الرعاية .سبب ترك العمل/Reason for Resignation],

  [المتدربات و مقدمي الرعاية .كيف تعرفت علينا/How Did the Applicant Hear about Us],

  [Attended Training/حضرت التدريب],

  [المتدربات و مقدمي الرعاية .Start Date/تاريخ البدء],

  [المتدربات و مقدمي الرعاية .End Date/تاريخ الانتهاء],

  [Group Year/سنة المجموعة],

  [Group Number/رقم المجموعة],

  [درجات نظرى/Theory Grade],

  [درجات عملى/Practical Grade],

  [درجات ميدانى/Field Grade],

  [اجمالى درجات/Total Grade],

  [42005],

  [42036],

  [42064],

  [42095],

  [42125],

  [42156],

  [42186],

  [42217],

  [42248],

  [42278],

  [42309],

  [42339],

  [42370],

  [42401],

  [42430],

  [42461],

  [42491],

  [42522],

  [42552],

  [42583],

  [42614],

  [42644],

  [42675],

  [42705],

  [42736],

  [42767],

  [42795],

  [42826],

  [42856],

  [42887],

  [42917],

  [42948],

  [42979],

  [43009],

  [43040],

  [43070];

   

LOAD

  [اسم/Name] AS [اسم-Name],

  [Type/النوع] AS [المتدربات و مقدمي الرعاية .Type/النوع],

  [الفرع/Branch] AS [المتدربات و مقدمي الرعاية .الفرع/Branch],

  [Gender/ الجنس],

  Date([تاريخ الميلاد/Date of Birth] ) AS [المتدربات و مقدمي الرعاية .تاريخ الميلاد/Date of Birth],

  [العنوان/Address] AS [المتدربات و مقدمي الرعاية .العنوان/Address],

  [District/حي] AS [المتدربات و مقدمي الرعاية .District/حي],

  [موبايل/Mobile number] AS [المتدربات و مقدمي الرعاية .موبايل/Mobile number],

  [تليفون آخر/Other Telephone] AS [المتدربات و مقدمي الرعاية .تليفون آخر/Other Telephone],

  [الحاله الأجتماعيه/Marital Status],

  [الموقف من التجنيد/Conscription Status],

  [الأمراض المزمنه/Chronic Illness],

  [Education/مستوى التعليم] AS [المتدربات و مقدمي الرعاية .Education/مستوى التعليم],

  [Specialisation/التخصص] AS [المتدربات و مقدمي الرعاية .Specialisation/التخصص],

  [سنة التخرج/Graduation Date] AS [المتدربات و مقدمي الرعاية .سنة التخرج/Graduation Date],

  [الوظيفه السابقه/Past Occupation] AS [المتدربات و مقدمي الرعاية .الوظيفه السابقه/Past Occupation],

  [سبب ترك العمل/Reason for Resignation] AS [المتدربات و مقدمي الرعاية .سبب ترك العمل/Reason for Resignation],

  [كيف تعرفت علينا/How Did the Applicant Hear about Us] AS [المتدربات و مقدمي الرعاية .كيف تعرفت علينا/How Did the Applicant Hear about Us],

  [Attended Training/حضرت التدريب],

  [Start Date/تاريخ البدء] AS [المتدربات و مقدمي الرعاية .Start Date/تاريخ البدء],

  Date(Date#([End Date/تاريخ الانتهاء], 'DD/MM/YYYY') ) AS [المتدربات و مقدمي الرعاية .End Date/تاريخ الانتهاء],

  [Group Year/سنة المجموعة],

  [Group Number/رقم المجموعة],

  [42005],

  [42036],

  [42064],

  [42095],

  [42125],

  [42156],

  [42186],

  [42217],

  [42248],

  [42278],

  [42309],

  [42339],

  [42370],

  [42401],

  [42430],

  [42461],

  [42491],

  [42522],

  [42552],

  [42583],

  [42614],

  [42644],

  [42675],

  [42705],

  [42736],

  [42767],

  [42795],

  [42826],

  [42856],

  [42887],

  [42917],

  [42948],

  [42979],

  [43009],

  [43040],

  [43070],

  [درجات نظرى/Theory Grade],

  [درجات عملى/Practical Grade],

  [درجات ميدانى/Field Grade],

  [اجمالى درجات/Total Grade]

FROM [lib://TFY/TFY For Qlik Master Sheet FINAL Copy.xlsx]

(ooxml, embedded labels, table is [المتدربات و مقدمي الرعاية ]);

[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');

DERIVE FIELDS FROM FIELDS [المتدربات و مقدمي الرعاية .تاريخ الميلاد/Date of Birth], [المتدربات و مقدمي الرعاية .Start Date/تاريخ البدء], [المتدربات و مقدمي الرعاية .End Date/تاريخ الانتهاء] USING [autoCalendar] ;

Problem:

The Dates from the crosstable created field named ([Date/التاريخ] in the [المتدربات و مقدمي الرعاية ] table unfortunately do not come up in DD/MM/YYYY form bur rather something like '426444'.


So I created a new section of the script and loaded this:

LOAD [المتدربات و مقدمي الرعاية ],

     Date(MonthStart(Num#([Date/التاريخ])), 'MM/YYYY') as MonthYear,

Year(num#([Date/التاريخ],'#')) as Year,

Month(num#([Date/التاريخ],'#')) as Month

Resident [المتدربات و مقدمي الرعاية ];

DROP Table [المتدربات و مقدمي الرعاية ];

When I load the script it gives me this:

The following error occurred:

Field 'المتدربات و مقدمي الرعاية ' not found

That is the table name though, I copied and pasted directly from the original script. If anyone can help me solve this I would be forever grateful! Also on the topic of date functions what is the script for adding Calender quarters? I only know how to do MonthYear, Year, Month and every attempt at Quarter has gone wrong! (If there is a demo somewhere with data for master calender that would be very helpful!)

Thank you everyone!

Best,

Mohammed

0 Replies