Hopefully someone has some advice, I have a a bit of arcade that I can't seem to get to work. The arcade script runs eternally without returning a result:
Solved! Go to Solution.
GroupBy is one of those functions that uses SQL. The value of expression has to be a valid SQL expression, not Arcade. Thankfully, Decode is something we can easily replicate in SQL using a CASE statement.
return GroupBy(
filteredFs,
['lead_contractor_name'],
[
{name: 'failed_count', expression: "CASE WHEN state = 'FAILED' THEN 1 ELSE 0 END", statistic: 'SUM'},
{name: 'successful_count', expression: "CASE WHEN state = 'SUCCESSFUL' THEN 1 ELSE 0 END", statistic: 'SUM'}
]
);
GroupBy is one of those functions that uses SQL. The value of expression has to be a valid SQL expression, not Arcade. Thankfully, Decode is something we can easily replicate in SQL using a CASE statement.
return GroupBy(
filteredFs,
['lead_contractor_name'],
[
{name: 'failed_count', expression: "CASE WHEN state = 'FAILED' THEN 1 ELSE 0 END", statistic: 'SUM'},
{name: 'successful_count', expression: "CASE WHEN state = 'SUCCESSFUL' THEN 1 ELSE 0 END", statistic: 'SUM'}
]
);
Brilliant, thank you!