Subscribe to Updates

    Get the latest business apps & software news from FMT.

    What's Hot

    FileMaker ReadQRCode & GetLiveText functions

    June 15, 2022

    Parallel Backups on FileMaker Server

    June 15, 2022

    Claris FileMaker Server 19.5 Overview

    June 15, 2022
    Facebook Twitter Instagram
    Trending
    • FileMaker ReadQRCode & GetLiveText functions
    • Parallel Backups on FileMaker Server
    • Claris FileMaker Server 19.5 Overview
    • Claris FileMaker 19.5 Overview | DB Services
    • NoSQL vs. Relational Databases | DB Services
    • Claris Problem Solvers Circle | DB Services
    • Business Days in Salesforce CRM Analytics (Tableau CRM)
    • FileMaker UPS Integration | DB Services
    Facebook Twitter Instagram YouTube
    SalesForce – FileMaker Business Software & Hosting SalesForce – FileMaker Business Software & Hosting
    Demo
    • Home
    • Features
      • Example Post
      • Typography
      • Contact
      • View All On Demos
    • Lifestyle

      Sci-fi Television Star Summer Glau Added to Next Play Launch

      March 15, 2021

      Season-less Fashion Trends are Now Reflecting Our Lifestyles

      January 19, 2021

      Windows 10 To Be Retired in 2025, As New OS Unveils

      January 18, 2021

      Average Mobile Data Usage Now Exceeds 10GB Per Month

      January 17, 2021

      Tom H is Ready To Take a Break After Spider-Man 3

      January 16, 2021
    • Typography
    • Travel
      1. Lifestyle
      2. Arts & Culture
      3. Food
      4. View All

      Sci-fi Television Star Summer Glau Added to Next Play Launch

      March 15, 2021

      Season-less Fashion Trends are Now Reflecting Our Lifestyles

      January 19, 2021

      Windows 10 To Be Retired in 2025, As New OS Unveils

      January 18, 2021

      Average Mobile Data Usage Now Exceeds 10GB Per Month

      January 17, 2021

      Guitarist John 5 Shreds at Sherman Theater in Stroudsburg

      March 13, 2021

      The New Home Decor Items and Collections We’re Excited About Now

      March 12, 2021

      Top 4 Composition Tips for Better Fashion Photography

      January 22, 2021

      10 New Designs, Design Firms Team Up to Launch This May

      January 22, 2021

      Austrians Dine Out Again After Virus Lockdown

      January 15, 2021

      The Best Places to Dine Out in Dingle This Summer

      January 15, 2021

      Is the Best New Fast-Food Chicken Sandwich By a Long Shot

      January 15, 2021

      Slim Chickens Bringing Fast-Food Restaurants to 9 Alabama Locations

      January 15, 2021

      Coronavirus: Greece is Officially Open — But Will the Tourists Come?

      March 14, 2021

      2m People Go Through US Airports, Travel Rebounds With Vaccination

      March 11, 2021

      Father’s Day Walks, Water Sports, & Meals in Plymouth

      January 15, 2021

      Review: Bucket List Destinations 2021 Across the Globe

      8.9 January 15, 2021
    SalesForce – FileMaker Business Software & Hosting SalesForce – FileMaker Business Software & Hosting
    Home » Business Days in Salesforce CRM Analytics (Tableau CRM)
    Uncategorized

    Business Days in Salesforce CRM Analytics (Tableau CRM)

    DBServicesBy DBServicesMay 18, 2022No Comments4 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email


    By
    Sabra Rathbun 

    Posted on 
    May 18th, 2022 

    in 
    Salesforce,

    Free Downloads

    It’s common for businesses to want to take business days into account when showing data on a dashboard in CRM Analytics (formerly Tableau CRM) to compare those figures to the last year’s same period. The problem is that CRM Analytics does not have a native set of functions to calculate business days; however, Sales Cloud does. We demo how to utilize Sales Cloud’s business hours object and some custom Apex to generate business days to sync to Analytics for dashboard queries.

    Setting Up Business Days Within Sales Cloud

    Business Hours and Holidays

    Before we dive into the Apex code, we have a few things to set up within Sales Cloud. To start, we need to set up our business hours and holidays. Business Hours is a standard object on the Salesforce platform that stores your company’s business hours and holidays. Setting up your business hours allows for Salesforce to automatically determine what is a business day or not. Salesforce does not account for observable holidays, though, which means you will have to build out your own code in Apex to work around that.

    Salesforce Business Hours Object

    After you have established your holidays and business hours within Sales Cloud, this information is ready to be used in your Apex code.

    Business Day Object

    To store your business day records, you will need to create a custom object. Ours is called “Business Day”. Our object has one custom field, which holds the date. This object will be used to record each individual business day in a given year.

    Salesforce Business Days Object

    Using Apex Code to Determine Business Days

    In order to create records in our Business Day object, we will need to leverage the isWithin standard Apex function on the Business Hours object. This function takes in the ID of your business hours and a Datetime variable as parameters and returns whether the given Datetime is within your business hours. In the example below, we use the ID of the default business hours and instantiate two Datetime variables, startDateTime and endDateTime.

    Id businessHoursId = [SELECT Id FROM BusinessHours WHERE IsDefault = true LIMIT 1].Id;
            if(startDate == null || endDate == null){
                return;
            }
            delete [select id from business_day__c where date__c >= :startDate and date__c <= :endDate];
           // Adding 12 hours to ensure the conversion of UTC to EST won't shift the date to the previous day
            DateTime startDateTime = DateTime.newInstanceGMT( startDate.Year(), startDate.Month(), startDate.Day(), 12, 0, 0);
            DateTime endDateTime = DateTime.newInstanceGMT( endDate.Year(), endDate.Month(), endDate.Day(), 12, 0, 0);

    Using the Datetime variables from above, we iterate through the starting date up to the end date and use the isWithin function to determine if the day is a business day. If the current day is a business day, it then creates a new Business Day record and adds it to a list. After it has gotten to the end date, the list is then uploaded into your database, and ready to be used in Analytics Studio. We recommend having this logic for generating the records automated with a scheduled automation that runs on the first day of the year to eliminate the hassle of running this manually every year.

    List<Business_Day__c> businessDays = new List<Business_Day__c>();
            while(startDateTime <= endDateTime){
                if(BusinessHours.isWithin(businessHoursId, startDateTime)){
                    Business_Day__c businessDay = new Business_Day__c();
                    businessDay.Date__c = startDateTime.Date();
                    businessDays.add(businessDay);
                }
                 startDateTime = startDateTime.addDays(1);
            }
    
            insert businessDays;

    Tableau CRM Analytics Studio

    Once we have the list of Business Day records for this year, we can use them in Analytics Studio as a data set. In order to use our data set in Analytics Studio, we have to create a dataflow that inputs our Business Day records. This dataflow has only two steps. In the first step, we are pulling in the date field from our custom Business Day object.

    salesforce crm analytics Pull in the Business Days Object

    The second step generates the data in Tableau CRM based on the parameters from the first step.

    salesforce crm analytics Create the Data Set

    Once you create your data set, you are able to use it within SAQL queries and on your dashboards in Tableau CRM. 

    Conclusion

    Creating a business days data set in Tableau CRM is a useful tool that can serve many purposes. You can create dashboards and limit SAQL queries to tailor your reports around your company’s business days, making a unique experience specific to your company. If you need help customizing your Tableau CRM Analytics Studio and Sales Cloud experience, contact DB Services today!

    Need help with your Salesforce digital transformation? Contact us to discuss Salesforce consulting, implementation, development, and support!

    Download

    Download the Calculate Business Days in Tableau CRM Demo File

    Please complete the form below to download your FREE Salesforce file.

    Sabra Rathbun thumbnail
    Sabra Rathbun

    Sabra is an enthusiastic and dependable application developer who is motivated by helping clients and coworkers succeed. Her positive attitude, accommodating nature, and consistency make her a valuable team member and a reliable developer.

    Analytics Business CRM Days Salesforce Tableau
    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Tumblr Email
    DBServices
    • Website

    Related Posts

    FileMaker ReadQRCode & GetLiveText functions

    June 15, 2022

    Parallel Backups on FileMaker Server

    June 15, 2022

    Claris FileMaker Server 19.5 Overview

    June 15, 2022

    Comments are closed.

    Demo
    Our Picks

    Noise-Cancelling Headphones For a Superb Music Experience

    January 15, 2020

    Harry Potter: 10 Things Dursleys That Make No Sense

    January 15, 2020

    Dubai-Based Yacht Company is Offering Socially-Distanced Luxury

    January 15, 2020

    The Courier – a New Song with Benedict Cumberbatch

    January 14, 2020
    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo
    Don't Miss
    Uncategorized

    FileMaker ReadQRCode & GetLiveText functions

    By DBServicesJune 15, 20220

    By Hayden Hobbs  Posted on  June 15th, 2022  in  FileMaker, Free Downloads, Mobile With the…

    Parallel Backups on FileMaker Server

    June 15, 2022

    Claris FileMaker Server 19.5 Overview

    June 15, 2022

    Claris FileMaker 19.5 Overview | DB Services

    June 15, 2022

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Your source for the lifestyle news. This demo is crafted specifically to exhibit the use of the theme as a lifestyle site. Visit our main page for more demos.

    We're accepting new partnerships right now.

    Email Us: info@example.com
    Contact: +1-320-0123-451

    Our Picks

    Noise-Cancelling Headphones For a Superb Music Experience

    January 15, 2020

    Harry Potter: 10 Things Dursleys That Make No Sense

    January 15, 2020

    Dubai-Based Yacht Company is Offering Socially-Distanced Luxury

    January 15, 2020
    New Comments
    • Twicsy on Coronavirus: Greece is Officially Open — But Will the Tourists Come?
    • https://62b2ffff12831.site123.me/blog/canadian-pharmaceuticals-for-usa-sales on Guitarist John 5 Shreds at Sherman Theater in Stroudsburg
    • https://62b2f636ecec4.site123.me/blog/canadian-pharmaceuticals-online on Guitarist John 5 Shreds at Sherman Theater in Stroudsburg
    • canadian discount pharmacies on Guitarist John 5 Shreds at Sherman Theater in Stroudsburg
    SalesForce – FileMaker Business Software & Hosting
    Facebook Twitter Instagram YouTube
    • Home
    • Lifestyle
    • Arts & Culture
    • Travel
    © 2022 FMT - MacLane Nova Digital Media - USA - Canada - Mexico - Sable Island - Bermuda - Isle of Man - Scotland - UK - France - Spain - Italy - Sweden - Australia - New Zealand -

    Type above and press Enter to search. Press Esc to cancel.