I have Calendar table and I want to join this table with multiple time dimensions present in parent cube(Employee). For example.
cube(`Employee`, {
sql: `SELECT * FROM \`DEMO\`.\`Employee\``,
joins: {
Calender: {
relationship: `hasMany`,
sql: `${Employee}.startDate = ${Calender}.full_date`
}
},
measures: {
count: {
type: `count`,
title: `Total Count`
}
},
dimensions: {
name: {
sql: `${CUBE}.\`name\``,
type: `string`
},
age: {
sql: `age`,
type: `string`
},
startdate: {
sql: `${CUBE}.\`startDate\``,
type: `time`,
title: `Start Date`
},
enddate: {
sql: `${CUBE}.\`endDate\``,
type: `time`,
title: `End Date`
}
}
});
How can I join the startDate
as well as endDate
column dynamically OR on demand. i.e. If my query timeDimensions
object contains endDate
then it should be automatically join with that column.
I already refered below links.
Following are my expectations.
Query: 1
{"measures":["Employee.count"],"timeDimensions":[{"dimension":"Employee.startDate"}],"dimensions":["Employee.startDate","Calendar.day","Calendar.month","Employee.endDate"]}
Expected Output:
{
"Employee.startDate": "2020-01-08T00:00:00.000",
"Employee.endDate": "2020-05-01T00:00:00.000",
"Calendar.day": "2020-01-08T00:00:00.000",
"Calendar.month": 01,
"Employee.count": 122
}
Query: 2
{"measures":["Employee.count"],"timeDimensions":[{"dimension":"Employee.endDate"}],"dimensions":["Employee.startDate","Calendar.day","Calendar.month","Employee.endDate"]}
Expected Output:
{
"Employee.startDate": "2020-01-08T00:00:00.000",
"Employee.endDate": "2020-05-01T00:00:00.000",
"Calendar.day": "2020-05-01T00:00:00.000",
"Calendar.month": 05,
"Employee.count": 122
}