PBI Desktop: Control X-Axis Labels

Hi all,

I am formatting a chart with share price values on the y-axis and date values (by day) on the x-axis. I am trying to control the x-axis labels for the chart. The chart is currently displaying the x axis in mmm yyyy format (ie Jan 2021, Jul 2021) by default. I would like to control the labeling using a field I built instead. This field displays the periods in quarters (ie Q1 '21, Q2 '21). The x-axis date values (by day) still need to be used to control their position since I have data for every day throughout this period, but the labeling should be controlled by the “quarter” field.

Does anyone have suggestions?

Thank you,
Matt

Similar to this question, can you convert (or Format) X-axis to a custom Text Field if axis Type was “quantitative” for graphic purposes? For example; I used “quarter” number 1-4 in a graphic to get in right order visually, but would like to replace with “1Q 2023”, “2Q 2023”…and so forth for the visual for the users.

“mark”: “line”,
“encoding”: {
“x”: {
“field”: “Layer one Q”,
“type”: “quantitative”,
“scale”: {“zero”: false},
“title”: “Quarter”

Hi @luz58. In Deneb, you can add an axis block to the x-encoding desired axis block complete with an expression to create the axis label you want. Here’s an example of creating your desired format:

{
  "data": {"name": "dataset"},
  "mark": "line",
  "encoding": {
    "x": {
      "field": "Quarter",
      "type": "quantitative",
      "axis": {
        "labelExpr": "datum.label + 'Q 2023'"
      }
    },
    "y": {
      "field": "Sales",
      "type": "quantitative"
    }
  }
}

Hope this helps.
Greg
eDNA Forum - Deneb Axis Label.pbix (1.3 MB)

Hello @matthew.u

Did the responses above help solve your query?

If not, can you let us know where you’re stuck and what additional assistance you need?

If it did, please mark the answer as the SOLUTION by clicking the three dots beside Reply and then tick the check box beside SOLUTION

Thank you

Hi @matthew.u

Due to inactivity, a response on this post has been tagged as “Solution”.

If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box.

We request you to kindly take time to answer the Enterprise DNA Forum User Experience Survey,.

We hope you’ll give your insights on how we can further improve the Support forum. Thanks!