We were tasked to help a client with their email campaigns. They want ask complex questions to get a list of account that match their criteria. The first, and simple, question they asked was to get a list of accounts that have open 5 low priority cases and have made an order this year. The client needs to be able to change these variables them self, the amount of orders, when the order was placed, amount of cases and what priority.
I have made a dataflow that collects all the data without any filter. We then want to provide a Lens, which is user friendly, with the filters pre-setup for them to tinker with. The account that you see in the screenshot has 6 cases, 4 low, 1 medium and 1 high priority.
The issue here is that the filters don't behave like we would expect it to be. I would expect the filter to first filter out any cases that arn't low priority and then check if there are 5 or more cases left (there should only be 4). This is obviously not happening.
Quick note before continuing: The dataset has account rows with each an array attached of cases and orders like your SObjects in apex. Not like SQL joins where you have multiple rows with all the data joined together in each row.
What I assume that happens is that the filter checks if the account as a single case with low priority and does not filter out the others. That check succeeds. It then check if it has 5 or more cases, since there are still 4 low, 1 medium and 1 high priority cases, 6 total, it succeeds.
My question is: can I get the filter, in the lens or with an other user friendly UI, to behave the way I would expect it to.
{
"sfdcDigest_Case": {
"action": "sfdcDigest",
"parameters": {
"fields": [
{
"name": "AccountId"
},
{
"name": "Id"
},
{
"name": "Priority"
},
{
"name": "Subject"
}
],
"object": "Case"
}
},
"augment_Account_Case": {
"action": "augment",
"parameters": {
"right_key": [
"AccountId"
],
"left": "sfdcDigest_Account",
"left_key": [
"Id"
],
"right_select": [
"Priority",
"Subject",
"Id"
],
"right": "sfdcDigest_Case",
"relationship": "Case",
"operation": "LookupMultiValue"
}
},
"register_Accounts_with_Orders_Cases": {
"action": "sfdcRegister",
"parameters": {
"name": "Accounts with Orders and Cases",
"alias": "Accounts_with_Orders_Cases",
"source": "merge"
}
},
"sfdcDigest_Account": {
"action": "sfdcDigest",
"parameters": {
"fields": [
{
"name": "Id"
},
{
"name": "Name"
}
],
"object": "Account"
}
},
"merge": {
"action": "augment",
"parameters": {
"right_key": [
"Id"
],
"left": "augment_Account_Order",
"left_key": [
"Id"
],
"right_select": [
"Case.Id",
"Case.Priority",
"Case.Subject"
],
"right": "augment_Account_Case",
"relationship": "Case",
"operation": "LookupMultiValue"
}
},
"sfdcDigest_Order": {
"action": "sfdcDigest",
"parameters": {
"fields": [
{
"name": "AccountId"
},
{
"name": "Id"
},
{
"name": "EffectiveDate"
}
],
"object": "Order"
}
},
"augment_Account_Order": {
"action": "augment",
"parameters": {
"right_key": [
"AccountId"
],
"left": "sfdcDigest_Account",
"left_key": [
"Id"
],
"right_select": [
"Id",
"EffectiveDate"
],
"right": "sfdcDigest_Order",
"relationship": "Order",
"operation": "LookupMultiValue"
}
}
}