Salesforce WAVE – XMD Explained

Blog by Stanley Sequeira | Oct 8, 2015


development

XMD – What exactly is it?

XMD stands for Extended Metadata. It allows you to customize the formatting of many dashboard elements in Analytics Cloud – Salesforce WAVE Platform

In this Chapter we’ll see modifying the following using XMD

  • Labels
  • Hide Measures / Dimensions
  • Formats
  • Keys
  • Colors
  • Value Query Columns

First things first, to modify XMD; you need to install Salesforce Dataset Utility. You can refer to my earlier post here for installing and logging into the Utility.

If you need to understand how to create / upload a data set, you can refer to my earlier post here

Once you’ve logged in –

Select the Opportunities Data Set; in the last Column you’d see Actions. Drill down on Actions and select EDIT XMD

10.1

You immediately see the XMD of the dataset which more or less would look something like this –

10.2

Now we’ll look at the each function one by one –


Labels


If you look for Labels in the XMD, you will see it contains two sections

  • Measures
  • Dimensions

It has a key-value pair, much like every other JSON artifact. The KEY here is the API Name whereas the VALUE is the Label.

In this exercise we’ll try to modify a Label of a field by just modifying the XMD.

Step 1: If you see StageName (API Name) has a value (Label) as Stage

10.3

Step 2:  Let’s change this label to let’s say Stage Name and click Submit XMD

10.4

Step 3: Now if you go back to the Dataset and Click Group, you would actually see the Label of Stage been changed to Stage Name instead

10.5

Here in this example I’ve renamed a Dimension, with the exact same approach you can also rename a Measure.


Hide Measures / Dimensions


This is a very powerful function wherein we can meet some business requirement of actually hiding an attribute from the view.

Step 1: We’re back on the same data set (Opportunities) and see the attribute Owner ID highlighted

10.6

Step 2: Go back to the XMD Editor Page

Step 3: Add the following code in there, just after types

"hide_dimensions": [
                       "OwnerId"
                    ],

10.8

Please Note – The hide_dimensions attribute takes only one parameter i.e. the API Name of the field dimension. In this Case the API Name of Owner ID field is OwnerID

Step 4: If any errors appear, the XMD Editor will point it out right away. If you do not see errors (most likely if you just copy the above code and paste it in the right location), you should be able to click Submit XMD without any difficulty

Step 5: Now if you go back to the Dataset and Click Group, you will not be able to find the Owner ID field in the list

10.9

Here in this example I’ve shown you have to hide a Dimension, with the exact same approach you can also hide a Measure.


Formats


The most common thing which you would typically do a lot more is the concept of Formats

Step 1: Let’s look at the Sales Rep Performance dashboard what I’ve setup

10.10

Step 2: If you see the Sum of Opportunity Amount is currently a number. Most likely we would want to see a currency format being displayed along with the big revenue number.

Step 3: Here in the example we’ll add the currency and two decimal places. Let’s go back to the XMD Editor. Here you need to search for the section which says formats (It’s ideal to minimize some sections before it gets too overwhelming)

10.11

Step 4: If you see the Amount array, it takes two things as a parameter. The first thing here is a blank array (“”) and the second thing is the multiplication factor (1).

Let’s replace this code with the blank array.

$#,##0.00

What this code essentially means:

  • ‘$’ – dollar Symbol before the value
  • Two decimal places after the value

10.12

Step 5: Let’s update the XMD and go back to the dashboard.

10.13

Here you’ll see the $ symbol and two decimal values.


Keys


Just like we’ve renamed the labels, we can actually rename the value of dimensions using the concept of Keys. Let me explain –

Step 1: Lets go back to the Same ‘Opportunities’ data set and this time group by the field ‘Won’

10.14

If you observe this dataset is grouped by two values ‘True’ and ‘False’. For this example we’ll like to change these keys to ‘Yes’ and ‘No

Step 2: Under the label we’ll paste the following code

"keys": {
       "IsWon": {
                       "true": "Yes",
                        "false": "No"
                       }
             },

10.15

If you observe closely, Keys takes just one parameter input i.e. the API Name of the field; the replacement value definition becomes as part of the field JSON

Step 3: Click Submit XMD and back to the dataset

Step 4: Here now you’ll see the new keys for the dimensions.

10.16


Colors


This concept works in conjunction with the keys. When you create a Chart, this attribute gives you the flexibility to change the color of the chart as per your choice.

Step 1: You should already be on the Lens created above (Opportunities Data Set and grouped by Won)

Step 2: Click on the Chart type and select Donut. You would see the ‘YES’ and ‘NO’ keys and some donut colors which you probably don’t like.

10.17

Step 3: Copy the following code and paste it right at the top above Types attribute

"colors": {
            "IsWon": {
                       "true": "#67CC8E",
                       "false": "#FF5600"
                      }
         },

10.18

Step 4: Submit the XMD and when you return back to the Chart, you’ll see the new colors been applied to the dashboard

10.19


Value Query Columns


This concept defines the columns which by default would be visible on the Raw Data Table Chart

Step 1: Click on the Opportunities Data Set

Step 2: Click on the Raw Data Table Chart type

10.20

Step 3: You’ll see right away that Analytics Cloud pulls in the first five columns available in the data set

10.21

Let’s say now you would like to change the default ordering of these columns.

Step 4: Let’s get to the XMD Editor page and paste the following code right at the bottom

  "values_query_columns": [
                               "Id",
                               "Type",
                               "CloseDate",
                               "Amount"
                           ]

10.22

Step 5: Once you submit the XMD and go back to the chart, you’ll see the default columns selected have changed.

10.23

All you need to do is get the exact API Name and the order in which you want them and place it under the values_query_columns attribute.

Hope this post helps you make your Salesforce WAVE development experience more pleasurable 🙂


3 thoughts on “Salesforce WAVE – XMD Explained

  1. Hi !
    Could you please help me with XMD2.0 format ?
    I cannot see the “types” in here.
    I have a blank skeleton with dimensions , derived dimensions , measures etc
    Is there I suppose to paste the colors ?

    thanks in advance !

    Like

Leave a comment