Question
write custom expression for grouping in record type
Here I want to get the most visited top 3 destinations and the count of journeys on each location.(relationship between 2 tables) So make an expression rule for that. but I need to do with record type with the use of a custom record field, here i found the custom expression rule, anyone guide me on how to use this code with a custom expression rule in record type? code below here
a!localVariables(
local!data:a!queryRecordType(
recordType: 'recordType!{64a0e01d-65e7-493d-8373-98dd241cb809}VS Journey',
fields: a!aggregationFields(
groupings: {
a!grouping(
field: 'recordType!{64a0e01d-65e7-493d-8373-98dd241cb809}VS Journey.relationships.{324614a4-84f3-45b4-bce2-95cbc8b65b6d}vsDestination.fields.{dbe0e7f1-b3d7-456b-9d82-e81a9042d256}name',
alias: "name_grouping1"
)
},
measures: {
a!measure(
function: "COUNT",
field: 'recordType!{64a0e01d-65e7-493d-8373-98dd241cb809}VS Journey.fields.{1209585a-f527-4ad9-b1fc-cc7ccc5dd973}destinationId',
alias: "destinationId_count_measure1"
)
}
),
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: 'recordType!{64a0e01d-65e7-493d-8373-98dd241cb809}VS Journey.fields.{75d3137b-b408-4bcb-8c31-ac2fd13e123a}customerId',
operator: "=",
value: 4
)
},
ignoreFiltersWithEmptyValues: true
),
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: a!defaultValue(value: 3, default: cons!VPA_DEFAULT_BATCH_SIZE),
sort: {
a!sortInfo(
field: "destinationId_count_measure1"
)
}
)
),
/*cast(194,local!data.data)*/
if(
ri!returnDataSubset,
local!data,
if(
local!data.totalCount > 1,
cast(194,local!data.data),
index(local!data,1,null)
)
),
)

