How to show numbers instead of strings for axis labels when using date column on x-axis

How to show numbers instead of strings for axis labels when using date column on x-axis

book

Article ID: KB0075169

calendar_today

Updated On:

Products Versions
Spotfire Analyst All supported versions

Description

When using a column of type "Date" for the X-axis in a visualization (for example a bar chart), and setting the X-axis to be Year > Month hierarchy, the X-axis labels for months will be strings, e.g. Jan, Feb, etc. An example of this is shown below.
User-added image
How to change the month labels from strings to numbers?

Environment

All supported environments

Resolution

A simple solution is to use Date() function on the X-axis, to the existing custom expression to instead show the lables like "1/1/2020", "2/1/2020", etc.

For the example above, the expression used on the X-axis is:
  • BinByDateTime([Date],"Year.Month",1)
Now just change the X-axis expression to:
  • Date(BinByDateTime([Date],"Year.Month",1))
and you will get the labels in numbers, as shown below.
User-added image

Issue/Introduction

This article explains how to show numbers instead of strings for axis labels when using date column on x-axis