How do I create zeros for null values in line chart?
I'm importing a SQL query that data and have included a batch date transform at the workbench level. I've joined the SQL query to the Calendar dataset so that dates are created for any weeks missing data which I was hoping would give me a 0 line on my chart for those days, but its not working. I've done this successfully in two other cases, but the difference in those cases was that the imported data was from Salesforce.
I've tried this in beast mode but that gives me an error: An issue has occurred during processing. We are unable to complete the request at this time.
(CASE
WHEN `System Name`='' or `System Name` LIKE '' then 0 ELSE COUNT(DISTINCT `System Name`) END)
I've also tried doing the count from the ETL and I'm able to get 0's to show up on the dataset, but not on the chart. Also, when I do it through the ETL, it takes hours to process due to the number of rows.
Currently, I'm trying to blend the calendar and SQL data matching the dt and 'batch date' columns. I'm just at a loss on what to do here. Any thoughts?
Comments
-
Are those values NULL or blank (''), I would guess its a NULL since you are left joining with the calendar dates and if the other dataset doesnt have the values then it gives a NULL in SQL.Either way this should work:
(CASE
WHEN `System Name`='' or `System Name` is NULL then 0 ELSE Count(DISTINCT `System Name`) END)0 -
I get the same error with that.
0 -
I could get it to work .
try this:CASE
WHEN TRIM(`System Name`)='' or `System Name` is NULL then 0 ELSE count(distinct `System Name`) END
0 -
That one says the formula is invalid. I tried it anyway but still get the same error.
0 -
I made an edit can you please try that.
0 -
Try now had left a random or in the middle :X
0 -
Valid query, same error.
0 -
Just to clarify, I'm trying to get a count of the number of distinct system names, even when the field is null. So in those cases, the count would be 0. I did try what you wrote and the error went away, but the chart says 'No data exists'.
0 -
If you also want a distinct count to include nulls then you'll add this:
COUNT (DISTINCT (CASE
WHEN `System Name` IS NOT NULL AND `System Name` <> '' THEN `System Name` ELSE 'Blank' END))If there are no valid system names found (only blank or null) your count returned should be 1.
0 -
I just don't want to see 1 on my chart when there are really 0. I don't want to count the null field. I just want it to show as 0 on the chart when it is null.
0 -
That error was because you were trying to use an aggregate function inside of a case statement.
0 -
@jlazerus If you want 0 when only null or blanks are present you can do try this:
CASE WHEN COUNT (DISTINCT (CASE
WHEN `System Name` IS NOT NULL AND `System Name` <> '' THEN `System Name` END))
> 0 THEN
COUNT (DISTINCT (CASE
WHEN `System Name` IS NOT NULL AND `System Name` <> '' THEN `System Name` END))
ELSE 0
END0 -
Still says 'No Data Exists'
0 -
try using the TRIM function after the `system_name` <> ''. I think the data might have blank system names as ' ' or maybe with more spaces in them.
Also, i dont think using distinct would produce the right result as the value is calculated row by row (my understanding), so the distinct will only match one to one which is always distinct1 -
There is another thread that was solved for this same question here.
Please let me know if this helps everyone out.
Thanks!
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 296 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 614 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 729 Beast Mode
- 53 App Studio
- 40 Variables
- 677 Automate
- 173 Apps
- 451 APIs & Domo Developer
- 45 Workflows
- 8 DomoAI
- 34 Predict
- 14 Jupyter Workspaces
- 20 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 121 Manage
- 118 Governance & Security
- Domo Community Gallery
- 32 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive