Conditional Formatting Workaround in Pivot Table

Hello,

Context:

In my organization, my role is cardbuilder. I have built a pivot table and ran into some issues with conditional formatting.

 

In my table, I have Daily Budget and Net Cost as two columns broken out by day. Ideally, I wanted the Net Cost column to turn RED (could be font or background - just something to flag it) if Net Cost > Daily Budget for that day. Given my data set has many different "advertising campaigns" that have different daily budgets, I cannot assign a specific dollar amount in the color rules. In an ideal world, I wish I could just tell it to turn red if Net Cost >  Daily Budget column in the setup. From what I read, this is just a current "limitation" on how conditional formatting works at the moment. 

 

As a "workaround", I created a new column called Overage. It basically shows the value if net cost exceeds daily budget for that day. (see screenshot). I did research and used a beast mode someone posted here that utilizes HTML as a workaround to spit out values in designated colors in my Overage Beast mode. This is the beast mode I used:

 

CASE WHEN (sum(`Net Cost`) - sum(`Daily Budget`)) > 0

THEN

CONCAT('<div style="background-color:#FF0000; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#FF0000">', sum(`Net Cost`)
-
sum(`Daily Budget`) , '</a></div>')

 

END

 

for some reason I keep encountering these issues:

 

  • No matter what color code I use in the beast mode, the result always ends up the color in my screenshot (bluish)
    • I tried adding in some <font> html codes, but no go
  • I set the data format for the beast mode as currency ($) with 2 decimals but it doesn't follow this.
    • is this because the beast mode shows up as "text string" vs "numeric"? How would I change that?

 

Any guidance would be helpful and appreciated!

 

Best Answer

  • user32470
    user32470 ⚪️
    Answer ✓

    ohh, I just found a workaround for this. Given the limitation on html markup for the pivot table, I modified my beast mode and then enabled "show negative numbers red" in the chart settings.

     

    I'm sure there are many ways to write this beast mode, but the change I made is in the second statement. Now, if there is an overage it will spit out a negative number and the "show negative numbers red" setting will flag it red. 

     

    CASE WHEN (sum(`Net Cost`) - (SUM(DISTINCT `Daily Budget`))) > 0

    THEN (sum(distinct `Daily Budget`)) - sum(`Net Cost`)

     

    END

     

    screenshot attached. thanks for helping everyone. i feel mildly successful for a Friday ?

Answers

  • GrantSmith
    GrantSmith Indiana 🥷

    Hi @user32470 

     

    You're getting bluish text because you have a hyperlink tag (<a href...) surrounding your text causing it to default to blue. Try taking out the <a> tags.

     

    Are you wanting the background to be red or the text to be red?

     

    Typically I've done the following to make the text red:

    CONCAT('<div><span style="color: red">', `field`, '</span></div>')

     



    **Was this post helpful? Click Agree or Like below**

    **Did this solve your problem? Accept it as a solution!**
  • jaeW_at_Onyx
    jaeW_at_Onyx Budapest / Portland, OR 🟤

    Unless they made changes AFAIK pivot tables don't have support for HTML formatting.  But let me know!

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • I tried that but what happens is it returns all the code starting with <DIV> in the pivot table. Per the other poster here it might just be a limitation on the pivot table. I'll try it on another type of table for my own learning but ultimately need the pivot table. I'll submit it as a product suggestion to domo. thanks all!

This discussion has been closed.