Formatting Variables

Hi, I am using a variable and some values are %, others are $. However, I the formatting doesnt seem to change when I try to switch them to a string by using concat and adding a % or $. They just come out as 1000 instead of $1000 or 57 instead of 57%.

Here is my beastmode. What might be causing this?

CASE
WHEN Pickup/Dropoff/Driving% = 'OnTime Pickup%' THEN CONCAT(ROUND(100*(1 - (SUM(PUPSTOPCOUNT_LATE) / SUM(PUPSTOP_COUNT))),0), '%')
WHEN Pickup/Dropoff/Driving% = 'OnTime Dropoff%' THEN CONCAT(ROUND(100*(1 - (SUM(DRPSTOPCOUNT_LATE) / SUM(DRPSTOP_COUNT))),0),'%')
WHEN Pickup/Dropoff/Driving% = 'Driving%' THEN CONCAT(ROUND(sum(DRIVING_HRS) / (sum(ON_DUTY_HRS) +sum(DRIVING_HRS)),0),'%')
WHEN Pickup/Dropoff/Driving% = 'Rev' THEN CONCAT('$',ROUND(((SUM(revenue) / COUNT(DISTINCT MPP_LASTFIRST)) / COUNT(DISTINCT LOG_DATE)),0))
WHEN Pickup/Dropoff/Driving% = 'Dwell' THEN ROUND((Sum(((UNIX_TIMESTAMP(STP_DEPARTUREDATE) - UNIX_TIMESTAMP(STP_ARRIVALDATE)) / 60)) / COUNT(DISTINCT STP_NUMBER)),0)
END

Answers

  • I'd recommend you split out each of your case statements into their own beast mode so you have just the formatting logic in each to see how each one applies to your data. This will help identify if there's an issue with your specific individual clauses or the entire beast mode.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • When I tried that idea (making all the lines a comment besides the one I wanted to test) none of them had the correct format. I even tried taking it out of the case statement and taking CONCAT(ROUND(100*(1 - (SUM(PUPSTOPCOUNT_LATE) / SUM(PUPSTOP_COUNT))),0), '%') but the % would not show up.

  • Jessica
    Jessica Contributor

    Are you specifically referring to the Variable option in DOMO which is different than a beast mode or are you just referencing the word variable as a descriptive identifier?

    If DOMO variable, in your example, which field is the DOMO variable?

    I would think you would need 2 DOMO variables to execute this, one that is % and one that is a $ and their is an option when you create the DOMO variable to select one of those.

  • Jessica I am new to variables so Im not sure what you are asking. I am using one drop down variable with a chart to the left. If the variable is selected to show x then it will display the value corresponding to that KPI (if its related to a percentage then display a % at the end or if its related to a dollar amount then display a $ at the beginning.)

    I use the variables name in the beastmode. For example

    case

    when Variables_name = x then display x's KPI

    when Variable_name = y then display y's KPI

    etc