Creating Progress Bar field using Formula| Without any coding

In this post we will discuss on creating Progress bar field without any coding, just by using formula field. Initially it seems like we can’t create dynamic progress bar field by using only formula in Salesforce. There are some approach, where developers stores 4 images with interval of 25% or 10 images with 10% interval and displaying image with help of Case or IF statement.

We will create Progress bar field, which will reflect every percentage.

Progress Bar using Formula field in Salesforce
Progress Bar using Formula field in Salesforce

To create perfect Progress bar field, we will need to take help of two images.

  1. Empty filled image with border (Download Sample)
  2. Filled rectangular image (Download Sample)

Upload above two images in Static resource. Once it is uploaded create a formula field.

In Formula field we will be appending both images and repeating “Filled Image” as per percentage field. Logic can be seen in below image.

Logic for Progress Bar using Formula field in Salesforce
Logic for Progress Bar using Formula field in Salesforce

Formula for Progress Bar Image

IMAGE('/resource/1398170360000/BlueProgressBar', 'Test', 10, ( percField__c * 100 )) &
IMAGE('/resource/1398170333000/ProgressBorder', 'Test', 10, (100 - percField__c * 100 )) &
' ' &
TEXT (percField__c * 100) &
'%'

In above code “1398170360000” is ID of static resource displayed in URL.

Posted

in

by


Related Posts

Comments

14 responses to “Creating Progress Bar field using Formula| Without any coding”

  1. Simrin Singh Avatar
    Simrin Singh

    Hello,

    How can this formula be used if i am using a visualforce page and the progress bar depends on a value from custom controller

    1. Jitendra Zaa Avatar

      Hi simran, in vf page you cannot use this. May ne ui can uae some library like jquery UI.

      1. Sonya Dhand Avatar
        Sonya Dhand

        Hi Jitendra

        Great post but I have an issue in that my bar will not expand width ways

        My formula is like this

        IMAGE(‘/resource/1490866928000/Opportunity_Progress_Bar’, TEXT(StageName),15,( percField__c * 100 )) &
        IMAGE(‘/resource/1490866874000/Opportunity_Progress_Border’, TEXT(StageName), 15, (100 – percField__c * 100 )) &
        ” &
        TEXT (percField__c * 100) &
        ‘%’

        But Cannot see all of the text

        Thanks

        Sonya

          1. Jitendra Zaa Avatar

            Seems you are using 2 images as “1490866928000” & “1490866874000” , URL of border image is not correct

          2. Sonya Dhand Avatar
            Sonya Dhand

            Hi Jitendra

            Thanks for getting back to me.

            I created 2 static resources for each image upload and the progress border url is correct. How would I get both images into the same static resource? So they have the same url?

            Thanks

            Sonya

          3. Sonya Dhand Avatar
            Sonya Dhand

            Hi Jitendra

            I re uploaded the image and all ok now.

            Thanks for you help

            Sonya

  2. Brent Downey Avatar

    This is awesome Jitendra, but my image isn’t displaying correctly in Salesforce. I made sure that the filler image is publicly available and in a shared document folder, but no luck. Any suggestions?

    1. Jitendra Zaa Avatar

      Hey brent, Thanks for feedback. It should be uploaded in Static resource and number is ID of static resource. I have updated this post.

    2. Brent Downey Avatar

      I actually got this to work. The issue was the URL I used for the image. Got this to work with ‘/servlet/servlet.FileDownload?file=01515000004mXEM’ as the URL where the ID provided is the Salesforce ID for the image. Thanks for this awesome information!

      1. Jitendra Zaa Avatar

        Awesome, you got it other way 🙂

  3. […] How to create formula bar using formulas – cool use case by Jitendra Zaa […]

  4. Gregg O Avatar
    Gregg O

    Hey Brent. Here is my code. What am I missing? My progress bar is showing up with the words test in it versus a shaded color. Thought? Thanks!

    IMAGE(‘/servlet/servlet.FileDownload?file=01536000001IOcr’, ‘Test’, 10, ( Reported_Committed__c * 100 )) &

    IMAGE(‘/servlet/servlet.FileDownload?file=01536000001IOcm’, ‘Test’, 10, (100 – Reported_Committed__c * 100 )) &

    ‘ ‘ &

    TEXT (Reported_Committed__c * 100) &

    ‘%’

  5. Chris Pearson Avatar
    Chris Pearson

    These progress bars look awful in Lightning Experience – any way to optimize for LEX?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading