Add a condition on line plot to toggle between AVG and SUM conditions
Hi,
I have a column in my data 'Volumes' and I am using that as Y-axis of line chart which is currently set to aggregate as SUM(Volumes). I have a problem with it where I want it to perform AVG(Volumes) when one condition is met and perform SUM rest of the times.
I am trying to perform this logic using calculated field, but when I drag the field in to the visualization, it says that an error has occurred. Please suggest any recommendations I can try to resolve the issue.
Here is the Beast mode calculation I am trying:
CASE WHEN COUNT(Plant
, Group
, Code
, Month
, Name
, Part Number1
, Part Number2
)>1
THEN AVG(Volumes
)
ELSE SUM(Volumes
)
END
Best Answer
-
The issue is with the count portion, are you looking for distinct row counts you can CONCAT all of the fields together:
COUNT(CONCAT(Plant, Group, Code, Month, Name, Part Number1, Part Number2))
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Answers
-
It is likely throwing any error because of how you are trying to use the count function. Are those individual fields within your dataset? The count function just takes one field: COUNT(plant) . If you are looking for any data in any of those fields, I would use the COALESECE function inside the COUNT function and list all of the fields inside the COALESCE function.
**Check out my Domo Tips & Tricks Videos
**Make sure toany users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
The issue is with the count portion, are you looking for distinct row counts you can CONCAT all of the fields together:
COUNT(CONCAT(Plant, Group, Code, Month, Name, Part Number1, Part Number2))
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
I think that worked well with CONCAT function. I dont see the error anymore. Thanks!
0 -
One other thing, if you want to see the unique count you can add a DISTINCT to the count before the CONCAT
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Categories
- All Categories
- Product Ideas
- 2.1K Ideas Exchange
- Connect
- 1.3K Connectors
- 309 Workbench
- 7 Cloud Amplifier
- 10 Federated
- Transform
- 664 Datasets
- 120 SQL DataFlows
- 2.3K Magic ETL
- 824 Beast Mode
- Visualize
- 2.6K Charting
- 86 App Studio
- 46 Variables
- Automate
- 194 Apps
- 486 APIs & Domo Developer
- 90 Workflows
- 24 Code Engine
- AI and Machine Learning
- 23 AI Chat
- 4 AI Projects and Models
- 18 Jupyter Workspaces
- Distribute
- 119 Domo Everywhere
- 283 Scheduled Reports
- 11 Software Integrations
- Manage
- 143 Governance & Security
- 11 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 116 Community Announcements
- 5K Archive