Field usage analysis

5
(4)

I cannot tell you how excited I am to be writing this blog and I think you will find this immensely helpful especially if you have had Tableau CRM (formerly Einstein Analytics) for a while. I find many users end up creating a lot of dataflows and bringing in a lot of fields because they can. Down the line these dataflows become slow and you start looking at how to optimize them. Well, one of the easiest ways to improve performance is to remove the fields that are not being used (doh!) however it’s not always that simple to figure out which fields you can remove. So Mohan Chinnappan has made this available in his SFDX plugin and added the fieldUsage command. The new command is part of the functionality of an earlier private chrome extension, however, this is not the only time the field usage problem has been tackled, work has been seen by Jason Huffman and Sagar Varma. Sagar’s solution even inspired taking the field usage analysis further making sure a csv could be loaded back into Tableau CRM to get a visual representation. Let’s have a look at how this new command works and how you can:

  • generate a csv file with all the fields in a dataflow
  • see if a field is used in a lens, dashboard or security predicate
  • create a dashboard of your dataflow field usage.

Get the plugin

I’ve previously gone through installing the plugin, so instead of walking through how to do that please refer to the Export your Einstein Analytics datasets blog.

Note: You need to both install the Salesforce CLI and Mohan’s plugin to continue to benefit from this blog. Check out the steps in Export your Einstein Analytics datasets.

If you already have the plugin you may very well need to update it to get the latest version. For my demonstration in this blog, I am using Apple’s terminal.

In Terminal we want to run the following command to update all the plugins.

sfdx plugins:update

Once this is done you can check the version of the installed plugins by using the following command:

sfdx plugins

As you can see the version I am using for this blog is 0.0.73, however, you may discover more updates have been made available and you have a later version.

Note: Check out the latest enhancements to fieldUsage in Github.

The fieldUsage command

The new command that has been added is the fieldUsage, so let’s have a look. To get the options for this command in terminal you can add the following command:

sfdx mohanc:ea:dataflow:fieldUsage -h

Let’s have a closer look at the options for this command.

Username

Use the -u option to specify a username to use for your command.

--The option
sfdx mohanc:ea:dataflow:fieldUsage -u <insert username>

--Example
sfdx mohanc:ea:dataflow:fieldUsage -u rikke@demo.org

Dataflow id

Use the -d option to specify a dataflow id to use for your command.

--The option
sfdx mohanc:ea:dataflow:fieldUsage -u <insert username> -d <insert dataflow id>

--Example
sfdx mohanc:ea:dataflow:fieldUsage -u rikke@demo.org -d 02K3h000000MtyuEAC

The dataflow list command

To use the fieldUsage command we need to have a dataflow id, which we can get by using the dataflow list command. To get the option for this command enter the following:

sfdx mohanc:ea:dataflow:list -h

Let’s have a closer look.

Username

Use the -u option to specify a username to use for your command.

--The option
sfdx mohanc:ea:dataflow:list -u <insert username>

--Example
sfdx mohanc:ea:dataflow:list -u rikke@demo.org

Extract the field usage

There is a prerequisite to be using this command, we need to know the dataflow id as you may have guessed when walking through the command options from before. Once we have that we are able to leverage the fieldUsage command. Finally, you will see that we get an output csv file we can use to import into Tableau CRM in order to visually display the field usage. However, before getting started make sure you are logged into your org.

Note: Before using the load command you would have to log in to the desired org by using the command sfdx force:auth:web:login, which will launch the login window in a browser.

Find dataflow id

As mentioned we need to find the dataflow id we want to use for our check. Hence we are going to use mohanc:ea:dataflow:list command, which is pretty simple as we only have to define the target org via the username.

Step 1 – use the dataflow:list command to extract the list of dataflows in the org.

sfdx mohanc:ea:dataflow:list

Step 2 – define the username for the target org by adding the -u option.

sfdx mohanc:ea:dataflow:list -u rikke@discovery.gs0

Step 3 – press enter.

Step 4 – find your the dataflow in question, copy the id and save it somewhere. I’m just adding mine to a text editor.

Check field usage

Next let’s look at how to check the field usage for the dataflow we picked in the steps above.

Step 1 – use the fieldUsage command from the plugin.

sfdx mohanc:ea:dataflow:fieldUsage

Step 2 – define the username for the target org by adding the -u option.

sfdx mohanc:ea:dataflow:fieldUsage -u rikke@discovery.gs0

Step 3 – define the dataflow to check by adding the -d option and use the id from the previous steps.

sfdx mohanc:ea:dataflow:fieldUsage -u rikke@discovery.gs0 -d 02KB0000000BRisMAG

Step 4 – press enter.

Step 5 – wait for the fieldUsage command to run and you will notice two files being generate a json and a csv file. You can copy the name and search for the file on your computer. You can ignore the json file and keep the csv file.

Step 6 – if you open the csv file you will find each field from the dataflow as well as the dataset name and if it’s used and where (dashboard, lens and security predicate).

Load field usage

We got the usage, but why stop here? Let’s load the csv file back into Tableau CRM as a dataset, so we can create a nice dashboard illustrating the field utilization and of course which fields might make sense to remove.

Note: To get more details on how the load command works please check out the blog Uploading datasets via CLI.

Step 1 – make sure the name of your csv file will not exceed 18 characters when uploaded. If it will rename the file – I’m calling mine fldusage.csv.

Step 2 – use the load command from the plugin.

sfdx mohanc:ea:dataset:load

Step 3 – define the username to use by adding the -u option.

sfdx mohanc:ea:dataset:load -u rikke@discovery.gs0

Step 4 – define what csv file and it’s location to use by adding the -d option.

sfdx mohanc:ea:dataset:load -u rikke@discovery.gs0 -d Desktop/fldusage.csv

Step 5 – press enter.

Step 6 – create a dashboard to see your field usage for your dataflow.

What more?

If you have many dataflows and you want to check the field usage from more than just one, you can use the fieldUsage command for the desired dataflows, you can then load the csv files but in the load command use the append operation to have one dataset with all the dataflows and datasets. Check out the Uploading datasets via CLI blog for more details on how to append your csv to a dataset during the load.

If you have any feedback or suggestions for the fieldUsage command please leave a comment on the blog. In the meantime, Mohan is continuing to develop new functionalities to the plugin incl. a dataflow visualization command to document what is happening in each node (sneak preview below).

How useful was this post?

Click on a star to rate useful the post is!

Written by


10 thoughts on “Field usage analysis”

  • 1
    Mathew on December 4, 2020 Reply

    This looks fantastic! I’m just curious, what metadata does it utilise from SalesForce/ Einstein Analytics to determine the usage? I would love to try and implement this in EADashboardHelper

  • 2
    Grace Hu on January 25, 2021 Reply

    Hello, Rikke:

    Thank you very much for these blogs, they’re really helpful because we’re working on optimizing our current data flows in EA. A couple of questions: how’s Mohan’s development on new functionalities? This will be another very useful feature we’d like to have; also, in EA, after a data flow, dataset could be further enhanced to a recipe. Is there any way to also analysis field usage for those classic recipe flows?

    Many thanks.
    Grace Hu

    • 3
      Lokesh on June 21, 2022 Reply

      Hey Grace:
      Even I have the field analysis task, do you have any idea how to deal with recipe? please let me know on raghurimlokesh@gmail.com

  • 4
    Grace Hu on January 27, 2021 Reply

    Hello, Rikke:

    How are you? I did go through this new blog: https://www.salesforceblogger.com/2020/11/18/dataflow-performance-with-field-usage-analysis/ where you showed Mohan’s new functionalities. My question now is: in the .csv file, does any fields which are only used in a data flow step like augment_xxx but not really been used in any lens or dashboards, will those fields’ usage be also seen in this .csv file? Plus this question: Is there any way to also analysis field usage for those classic recipe flows?

    Many thanks,
    Grace Hu
    Senior Data Systems Architect

  • 5
    Sid on February 9, 2021 Reply

    Search, download, categorize, visualize, and optimize all of your Salesforce org’s metadata with “Plus”. A comprehensive metadata dictionary. 

    Learn more: https://sidagarwal22.medium.com/plus-metadata-dictionary-for-salesforce-5ad546479e6b

    Free Download: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000ONDwTEAX

  • 6
    Lokesh on June 14, 2022 Reply

    Awesome blog. It is working for dataflow how about the recipe please?

    • 7
      Rikke on June 14, 2022 Reply

      Not yet…

      • 8
        Gabi on April 5, 2023 Reply

        Hello Rikke! Fantastic tool, thank you! Just follow up on behalf of few of us.. Is there a possibility to assess field usage, when dataset is built in a recipe?

  • 9
    Nilu on March 23, 2023 Reply

    Hi,

    Is there any plugin/commands available to find field usage from recipe now?

  • 10
    Zac Otero on December 7, 2023 Reply

    Bumping this again to ask if the fieldUsage function has plans to be updated for Recipes.
    Extremely useful for auditing field usage and trimming down bloated Datasets.
    Fingers crossed that this happens soon!!

Leave a Reply to Mathew Cancel reply

Your email address will not be published. Required fields are marked *

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