Hello,
I have created a View with two tables. One is the Date table and another with EmployeeSickTable. I want to fetch data from another table in my view but that table has one to N relation.
My Date table has the below data.
| From Date |
| 01/10/2020 |
| 02/10/2020 |
| 03/10/2020 |
| 04/10/2020 |
| 05/10/2020 |
| 06/10/2020 |
| 07/10/2020 |
| 08/10/2020 |
| 09/10/2020 |
| 10/10/2020 |
EmployeeSickTable
| Employee Id |
SickId |
Sick% |
| 1 |
1001 |
100 |
| 2 |
1002 |
60 |
SicknessDetails
| SickId |
Sick% |
Valid from |
Valid to |
| 1001 |
100 |
01/10/2020 |
05/10/2020 |
| 1001 |
60 |
06/10/2020 |
10/10/2020 |
My View Structure
DateTable >> EmployeeSickTable ( There is no join here because I want to get Employee sickness data per day)
If I add join with EmployeeSickTable >>SicknessDetails then It shows multiple lines which I want to avoid.
I want to see the below data with two table structure like DateTable >> EmployeeSickTable
My view should be like this
| From Date |
Employee |
SickId |
Valid From |
Valid to |
Sick% |
| 01/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
100 |
| 02/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
100 |
| 03/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
100 |
| 04/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
100 |
| 05/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
100 |
| 06/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
60 |
| 07/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
60 |
| 08/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
60 |
| 09/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
60 |
| 10/10/2020 |
1 |
1001 |
01/10/2020 |
10/10/2020 |
60 |
I have created a computed column like this
private static str computeSickPercent()
{
SicknessDetails sicknessDetails;
str trendDateStr = SysComputedColumn::returnField(
tableStr(MyView),
tableStr(DateTable),
fieldStr(DateTable, TrendDate)) ;
str SickIdHeader = SysComputedColumn::returnField(
tableStr(MyView),
tableStr(EmployeeSickTable),
fieldStr(EmployeeSickTable, SickId)) ;
TransDate trendDate= str2date(trendDateStr,213);
EmployeeSickTable employeeSickTable = EmployeeSickTable::find(SickIdHeader);
select validtimestate(trendDate) sicknessDetails
where sicknessDetails.SickId == employeeSickTable.sickId;
return num2Str(sicknessDetails.Sick%,-1,-1,2,2);
}
I want to calculate Sickness % per day based on a date table but it is showing null values.