% calculation for a table card
I need to calculate the percentage in a table card, the table like this:.
I want to calculate the % based on Sent. e.g delivered % =4800/5000, Total bounce % =120/5000.
I wrote this beast mode, but return nothing, can you please let me know what is not working.
Thank you.
Olivia
SUM(
CASE
WHEN `Category` IN ('Delivered','Total Bounce','Opens','Unsubscribes')
THEN (`total`) END)
/(SUM(
CASE
WHEN `Category` IN ('Sent')
THEN (`total` )
END))
Category  total  % 
Sent  5000  
Devliered  4800  96% 
Total bounce  120  2.4% 
Opens  900  18% 
Unsubscribes  24  0% 
Comments

I believe that Beast Modes can only perform calculations on rows, which means we may not be able to display your data in a vertical table perfectly.
Depending on how your data set is structured you have a few options... See the attached PDF for scenarios I have drawn up for you.
1 
Hello, DDalt,
thank you for your help. My data is stored in option 1 in your pdf. Unfortunately, what I am showing is what my stakeholders would like to have. I hope I can do it in the way they want. Any other ideas?
Thank you.
Olivia
0 
Sure! So in this case, we will need to add a column to our original data that stores the Total Sent value next to each value. This will enable us to perform a calculation on each row where we can divide the metric value by the Total Sent value.
I've attached another PDF of how I did this using a Redshift transform and how you can build your table in Analyzer using beast mode.
0 
Hi, DDalt,
Thank you for your help. I did as what's in your data flow. However, there is another issue now: In the data flow, the total is for all 'Sent' for all data I have, however, in my card, I only wanted to show for a certain time period, even better, I would like to give user the ability to select the date range, thus the total sent is changing based on the filters. Therefore, the % is not correct.
Any other ideas?
Thank you very much.
Olivia
0 
Hey Olivia,
I updated my data set to include a date column and am attaching an example of a window function you can use to select the maximum value for each day (which should be the "Sent" value") and ascribe it to each row within that day.
If you send multiple emails per day, you could consider partioning by 'email_name' instead of date which would give you the largest value for each email sent
0
Categories
 All Categories
 1.8K Product Ideas
 1.8K Ideas Exchange
 1.5K Connect
 1.2K Connectors
 297 Workbench
 6 Cloud Amplifier
 8 Federated
 2.9K Transform
 100 SQL DataFlows
 616 Datasets
 2.2K Magic ETL
 3.8K Visualize
 2.5K Charting
 729 Beast Mode
 54 App Studio
 40 Variables
 678 Automate
 173 Apps
 451 APIs & Domo Developer
 46 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