Best Of
Re: Division by Zero ETL error
Hi @Emma
You need to check for your denominator to be zero, not your numerator. Try this (will return 0 if `Conservative Max Qty per plt` is 0)
CASE WHEN `Conservative Max Qty per plt` = 0 THEN 0 ELSE `Total Stock`/`Conservative Max Qty per plt` END
Re: How to Create Monthly Averages for Headcount?
I'm not certain what all information you need displayed on your card but you could utilize the LAG window function assuming you don't have any missing months:
Average Head Count (Beast Mode)
( SUM(SUM(`EmployeeCount`)) OVER (PARTITION BY `EOMDate`) + LAG(SUM(`EmployeeCount`), 1) OVER (ORDER BY `EOMDate`)) / 2
Re: How to Create Monthly Averages for Headcount?
I'm glad you got it figured out! I was going to suggest programmatically calculating the number of months to divide by depending on the current year and month (untested - back of napkin):
(CASE When YEAR(`EOMDate`) = YEAR(CURRENT_DATE) Then SUM(`TermCount`)/ ((SUM(`ActiveCount`))/MONTH(CURRENT_DATE)) When YEAR(`EOMDate`) = YEAR(CURRENT_DATE) - 1 Then SUM(`TermCount`)/ ((SUM(`ActiveCount`))/12) Else 0 End)
Re: how to show a duplicate in a table graph
The code I provided should have a Filter -> Group By -> Filter and it should automatically have the code pre-filled out. Do you see it elsewhere in your ETL canvas? I'm guessing because the dataflow I copied it from is quite large it might be off your screen and you'll need to scroll down. Alternatively I've attached some screen shots below outlining how I've done it.
Hopefully this helps clear things up.
Re: Workbench | Multiple Accounts in One DOMO Instance
When I create a dataset I'll make sure to add some tags on the dataset denoting the workbench server so I know which workbench server specifically this data came from. It's an extra step and I haven't found an easy way to automated it yet but it's been tremendously helpful to make sure we can track down the source of a dataset.
Another alternative is you can utilize a prefix on your datasets like [DEV] or [PROD] so you know one is a development dataset and the other is a production dataset.
Re: Progress Bar Gauge visuals
Case statements are helpful in situations like this where you want to conditionally add things together.
SUM(CASE WHEN `IsRead` = 'True' THEN 1 ELSE 0 END) / COUNT(`Username`)
Essentially we're saying give me a 1 if IsRead is True otherwise give me a 0 and then adding all the values together.
This should allow you to calculate your percentage without having to process it through an ETL and stripping out the False values.
Re: Aggregation by month with segmentation
Hi @GrantSmith
Thanks so much, I was finally able to do this! Great explanation combined with the screens! I just needed to do some tweaks to count unique days per user instead of activities.
Best, Stefan

Re: Progress Bar Gauge visuals
Thanks @GrantSmith that seems to have worked
I wasn't far off with the Beast Mode statement. Just missed the / COUNT(`UserName`) at the end.
Thanks for all your help.

Re: Aggregation by month with segmentation
Hi @Stefan
Since you're wanting to aggregate an aggregate you won't be able to do it directly in a card. I'd recommend using a Magic ETL dataflow to do your grouping based on the `User ID` field and count how many records you specifically have for each user. Then you can use the new activity count field as your series and use the count of user IDs as your y-axis and date as the x-axis
Here's the ETL:
{"contentType":"domo/dataflow-actions","data":[{"name":"user-segementation-example-file.xlsx","id":"e49f16af-51ba-47c8-b1ab-728cad8e0de6","type":"LoadFromVault","gui":{"x":36,"y":180,"color":3238043,"colorSource":null},"dependsOn":[],"removeByDefault":false,"notes":[],"dataSourceId":"cc851b6c-536e-4d75-97d4-3761d3a5ee58","executeFlowWhenUpdated":false,"onlyLoadNewVersions":false,"columnSettings":{},"visiblePartitionColumn":null},{"name":"Add Formula","id":"19a79f63-28f3-4ccc-8052-d013fa72a151","type":"ExpressionEvaluator","gui":{"x":156,"y":180,"color":null,"colorSource":null},"dependsOn":["e49f16af-51ba-47c8-b1ab-728cad8e0de6"],"removeByDefault":false,"notes":[],"expressions":[{"expression":"LAST_DAY(`Date`)","fieldName":"Month","settings":null}]},{"name":"Group By","id":"500baa72-f4ac-402a-a50f-f1485438884e","type":"GroupBy","gui":{"x":282,"y":180,"color":null,"colorSource":null},"dependsOn":["19a79f63-28f3-4ccc-8052-d013fa72a151"],"removeByDefault":false,"notes":[],"addLineNumber":false,"lineNumberFieldname":null,"giveBackRow":false,"allRows":false,"groups":[{"name":"Month"},{"name":"User ID"}],"partitionedAggregation":false,"fields":[{"name":"Activity Count","source":"User ID","type":"COUNT_ALL","valuefield":null}]},{"name":"User Segmentation Example","id":"ac564bae-7aaa-43d8-86c5-db0bb39082c5","type":"PublishToVault","gui":{"x":408,"y":180,"color":null,"colorSource":null},"dependsOn":["500baa72-f4ac-402a-a50f-f1485438884e"],"removeByDefault":false,"notes":[],"dataSource":{"guid":"8973681c-2028-41ad-8e35-a200177fcd4c","type":"DataFlow","name":"User Segmentation Example","description":"https://dojo.domo.com/discussion/53828/aggregation-by-month-with-segmentation#latest","cloudId":"domo"},"versionChainType":"REPLACE","partitionIdColumns":[]}]}
You can paste that in the a New Magic ETL dataflow and should populate everything for you. If not here are some screen shots:
Re: Case Statement (dividing by specific conditions)
I personally don't like that type of aggregation filters...
Can you try this, and check the numbers...
IFNULL(
SUM(`CompletedOffers`)
/
NULLIF(SUM(`SettledOffers`),0),0)
If you don't need the zero in case `SettledOffers` are zero and can live will null use :
SUM(`CompletedOffers`)
/
NULLIF(SUM(`SettledOffers`),0)
Any of the formulas will avoid divide by zero problems, because fortunately in most SQL flavors
X/0 = ERROR but X/NULL = NULL, I think this is a very important concept when doing divisions in Beast Mode (or SQL in general)
It should, in theory, get the same results of your formula but without aggregations inside conditional elements.
Hope this helps.Tell me how it does.
