Best Of
Re: Beast mode to extract the date based on a pattern
Try this to deal with the additional scenarios
DATE( CASE WHEN LEFT(`description`,5) = '*SLD ' THEN IFNULL(TRY_CAST(SPLIT_PART(`description`,' ',2) AS DATE),`orddate`) WHEN LEFT(`description`,4) = '*SLD' THEN IFNULL(TRY_CAST(SPLIT_PART(REPLACE(`description`,'*SLD',''),' ',1) AS DATE),`orddate`) ELSE `orddate` END)
Re: Can someone give me DDX Bricks examples which use traditional SQL (using JOIN) to query?
Have you looked at the "DDX SQL Input Bar Chart Output" DDX brick in the app store? You'd need to specify the different datasets in your DDX brick but you should then be able to utilize your join.
Re: Using Python API to Update Already Created Datasets
@ElliotGitter where is your dataset coming from? Is it updating from somewhere else too?
Once you've created the dataset using the API, you can always update it using the API (it's not like everytime you run your python script you have to create a new dataset to update). If you can create a new dataset using the API, update it once with the data in yourcurrent dataset, then moving forward you can update that dataset you created with your python script.
mhouston
Re: Scatter Chart Bubble Color
In the chart properties you can set the color rules. So depending on your dataset, you can set a color rule when that field is 0 to green and less than 0 to red.
mhouston
Re: Replace text and value mapper failing
I would suggest moving away from the replace text and value mapper tiles and use the formula tile in your ETL. It is much more flexible and you can do all your work in a single tile.
You can do something like this in the formula tile.
CAST( CASE WHEN `field` = '#DIV/O' THEN 0 WHEN `field` = '--' THEN 0 ELSE `field` END as INTEGER)
You can add additional WHEN statements for other variations that your data might have. You might also want to use the TRIM function around your field in case there are spaces.
Another option is this where it tests to see if it can convert it to an integer and using the number if it can, otherwise it will make it a zero.
CAST( CASE WHEN TRY_CAST(`field` as INTEGER) > 0 THEN `field` ELSE 0 END as INTEGER)
You could use NULL instead of 0 in your ELSE statement if that is more appropriate.
Hope this helps.
Re: Requests Older than 6 Days
Hi @Fadem
You need to change the order if using "greater than or equal to" 6
like this
SUM(case when DATEDIFF(CURRENT_DATE(),`Effective Time`) >=6 then 1 else 0 end)
DP22 - Using Beast Mode to Build Data Storytelling - Links and Images
This post is part of a series of beast modes I presented on during my “Using Beast Mode to Build Data Storytelling” Domopalooza 2022 session. If you find this post helpful please make sure to give it a like or an awesome below.
Use Case
We wanted to enhance the visualization experience and allow users to see which specific item we’re referencing with an image rather than just a specific ID code. Another think we wanted to do was to allow users to click on the image or hyperlink to go to the website to get more information on the product rather than having to look it up themselves. We utilized a Mega Table for this but the beast mode will also work in an HTML table if desired.
Beast Mode
CONCAT( '<A HREF="https://my.url.com/store/detail/', `Product ID`, '" TARGET="_blank">', '<IMG SRC="https://my.url.com/images/items/', `Product ID`, '-small.jpg"/>', '</A>’)
Beast Mode Breakdown
Hyperlinks
CONCAT('<A HREF="https://my.url.com/store/detail/', `Product ID`, '" TARGET="_blank">@</A>’)
Generates HTML code to create hyperlink for users to click on by dynamically creating the URL with the correct product ID. For example: <A HREF="https://my.url.com/store/detail/SM58" TARGET="_blank">@</A>
TARGET="_blank" causes the link to open in a new tab instead of replacing the existing window. This is important because if it’s opened in a new window and a user clicks back to get back to the card they will lose all of their filtering. Opening a new tab allows the card to still exist with the filtering in place giving a much better user experience.
Whatever is in between the <A> and </A> tags will be highlighted for the user to click on and go to the URL defined in the HREF. In this example @ is the text that will be highlighted for a user to click.
Can only use mailto, http and https protocols in hyperlinks.
Images
CONCAT('<IMG SRC="https://my.url.com/images/items/', `Product ID`, '-small.jpg"/>’)
•
Dynamically generate the URL of the image using the product ID For example: https://my.url.com/images/items/SM58-small.jpg
CONCAT wraps the dynamic URL in HTML IMG tag to tell the browser to display an image
Images & Hyperlinks
CONCAT( '<A HREF="https://my.url.com/store/detail/', `Product ID`, '" TARGET="_blank">', '<IMG SRC="https://my.url.com/images/items/', `Product ID`, '-small.jpg"/>', '</A>’)
Combines the logic from the Link beast mode with the Image beast mode to allow for users to click on the image to open the link.
We’ve replaced the @ in the Link beast mode
Final Result
Clinking the image takes you to the webpage defined in the A tag's HREF URL.
DP22 - Using Beast Mode to Build Data Storytelling - Sales Pacing Graph
This post is part of a series of beast modes I presented on during my “Using Beast Mode to Build Data Storytelling” Domopalooza 2022 session. If you find this post helpful please make sure to give it a like or an awesome below.
Use Case:
We needed a way to display and estimate in real time how well our sales were pacing for the current month to allow stakeholders to quickly make informed decisions. To do this we created a sales pacing graph to determine the current month’s running total and where sales are projected to be at the end of the month.
Beast Modes:
Running Total
SUM(SUM(`Daily Sales`)) OVER (PARTITION BY LAST_DAY(`Order Date`) ORDER BY `Order Date`)
Run Rate:
SUM(SUM(`Daily Sales`)) OVER (PARTITION BY LAST_DAY(`Order Date`) ORDER BY `Order Date`) / DAYOFMONTH(`Order Date`) * DAYOFMONTH(LAST_DAY(`Order Date`))
Beast Mode Breakdown:
Running Total
SUM(SUM(`Daily Sales`)) OVER (PARTITION BY LAST_DAY(`Order Date`) ORDER BY `Order Date`)
OVER denotes a window function. Window functions in beast modes are a feature switch. Talk with your CSM to get this enabled.
Window functions allow us to calculate an aggregation across the partition or entire dataset and return that value as a single value within each row.
PARTITION BY LAST_DAY(`Order Date`)
PARTITION BY Defines the bucket we want to aggregate over
Can exclude to aggregate over the entire dataset.
LAST_DAY returns the last day in a month. This is a way to group by each month. It’s an alternative to (PARTITION BY YEAR(`Order Date`), MONTH(`Order Date`))
ORDER BY `Order Date`
Defines the order in which to calculate the running total.
If excluded it will be the grand total within your partition.
SUM(SUM(`Daily Sales`))
Normal SQL is a single aggregation however Domo can potentially do aggregation twice. First when the data is initially loaded into the card. Another time when you have selected aggregation on another field on the card.
Because a window function returns a single value for each row we need to tell Domo how to aggregate the data (again) when the card does aggregation.
Run Rate
SUM(SUM(`Daily Sales`)) OVER (PARTITION BY LAST_DAY(`Order Date`) ORDER BY `Order Date`) / DAYOFMONTH(`Order Date`) * DAYOFMONTH(LAST_DAY(`Order Date`))
SUM(SUM(`Daily Sales`)) OVER (PARTITION BY LAST_DAY(`Order Date`) ORDER BY `Order Date`)
This is the Running Total beast mode from above. We want to get the month's total at the date given.
/ DAYOFMONTH(`Order Date`)
Divide by the day number of the order date (DAYOFMONTH) to get the average amount per day. In other words the number of days that have elapsed in the current month as of the Order Date
* DAYOFMONTH(LAST_DAY(`Order Date`))
LAST_DAY returns the last date in the given month. DAYOFMONTH will tell us the day number of the last day of that month. In other words, the number of days in the given month. Multiplying our average we just calculated will give us an estimate for the end of the month as of the Order Date value.
Final Result:
Re: Assigning blank value as Zero
COALESCE(`rate`, 0)
Coalesce also works. It returns the first non-null value supplied. This is assuming your data is actually NULL and not an empty string. If it is you can force it to be null:
COALESCE(NULLIF(TRIM(`rate`), ''), 0)
TRIM to strip whitespaces at the beginning and end of the string for good measure.
Also to address your beast mode IFNULL will return a value but it's not evaluating to TRUE for FALSE as the case statement expects. This is why you're getting an error.
Re: Scheduled Reports
Unfortunately, when a table is the scheduled report, Domo is essentially taking a picture of the table card and including it in the body. It is a fixed width and can't be adjusted. It would be a nice enhancement if the full table card was included, though.




