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 to any 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
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 748 Beast Mode
- 60 App Studio
- 41 Variables
- 689 Automate
- 177 Apps
- 454 APIs & Domo Developer
- 48 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 397 Distribute
- 114 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 127 Manage
- 124 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 109 Community Announcements
- 4.8K Archive