custom progress bar on drill down popup table cell

Recently I was strugling with the cell visualization (progress bar) on table displayed on drill down.
Because I haven’t found any resonable source or example of how to do it, I’ve decided to share my solution here.

the problem

we have a measure with drill_fields parameter with 3 fields

  measure: usage_total {    

type: count     drill_fields: [criteria_sub_group, criteria_name, usage_total]   }

and when drill down popup appears - it looks similar to this

4c1f48e0-3029-4d37-9b05-0c845537fece.png

say we want to have these progress bars in one color (not as a gradient of values)

the solution

add another measure as a percentage of total

  measure: pot {    

    type: percent_of_total    

    value_format: "0.00\%"    

    sql: ${usage_total} ;;  

  }

then add html param to visualized measure

  measure: usage_total {

    type: count

    drill_fields: [criteria_sub_group, criteria_name, usage_total]

    html:

        <div style="width:100%;">

          <div style="float:left; background:#A5CFE6; width:{{pot._rendered_value}}%;

               height:15px; margin:3px 0px 5px 0px; padding:2px 0px 2px 0px; border-radius:1px;">

          </div>

        <div style="float:left; margin:4px 0px 0px 5px; font:12px Roboto; font-weight:700; text-align:left;">

          {{rendered_value}}

        </div>

      </div>

     ;;


  }

the result

30e93304-af3f-432e-b5c9-e2054705aa1e.png
  • bars widths are scaled to a percentage of the “parent” value
    (which is IMO more natural)
  • notice that tooltip on “parent” value is also visualized
0 0 383
0 REPLIES 0
Top Labels in this Space