Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
HG_16159
New Member

X-axis with day and month

Hi, 

I've been browsing posts but can't seem to find a solution that actually works with my data. I'm a bit of a newbie still, but am enjoying learning a new way to present data that isn't R. 

Below I have two graphs. The bottom one looks exactly the way I would like it, except the x-axis is based off DOY, and the top graph has the correct x-axis, but vis is all wrong. 

HG_16159_0-1741368665565.png

 

Things I've tried: 

- Drilling up a level

HG_16159_1-1741368934417.png

- Changing the date hierarchy / trip_start_date back and forth between continuous & categorical. 

- Making all sorts of date columns in different formats to use as labels: 

HG_16159_2-1741368971689.png

 

I'm sure there is an easy solution. I appreciate your kind responses.

 

Data: 

trip_seq_notrip_start_dateYearDOYeffort_seq_nolocation_idSI_density
32189154367620192115440135LLS-21.525062
32189154367620192115440136LLS-20
32189154367620192115440137LLS-20
32189154367620192115440138LLS-30
32189154367620192115440139LLS-30
32189154367620192115440140LLS-31.715833
32189174369320192285440159LLS-20
32189174369320192285440160LLS-20
32189174369320192285440161LLS-22.005025
32189174369320192285440162LLS-31.873758
32189174369320192285440163LLS-31.864666
32189174369320192285440164LLS-30
32189194371820192535440183LLS-20
32189194371820192535440184LLS-20
32189194371820192535440185LLS-211.52958
32189194371820192535440186LLS-311.45957
32189194371820192535440187LLS-33.397393
32189194371820192535440188LLS-30
32189434400720201775440231LLS-25.385557
32189434400720201775440232LLS-25.290581
32189434400720201775440233LLS-28.109403
32189434400720201775440240LLS-33.306965
32189434400720201775440241LLS-30
32189434400720201775440242LLS-314.44517
32189464402820201985440267LLS-210.12216
32189464402820201985440268LLS-20
32189464402820201985440269LLS-20
32189464402820201985440276LLS-33.137031
32189464402820201985440277LLS-31.584843
32189464402820201985440278LLS-30
32189484404120202115440291LLS-20
32189484404120202115440292LLS-20
32189484404120202115440293LLS-20
32189484404120202115440300LLS-30
32189484404120202115440301LLS-32.077579
32189484404120202115440302LLS-30
32189544409320202635440357LLS-21.946817
32189544409320202635440358LLS-21.995736
32189544409320202635440359LLS-20
32189544409320202635440360LLS-30
32189544409320202635440361LLS-30
32189544409320202635440362LLS-30
1 ACCEPTED SOLUTION
HG_16159
New Member

We solved this issue by converting our graph to a Denebe object, with the code below. While I lost the slider functionality, I retained the bulk of the functionality in the graph and can continue to filter the data based off location & year. It's frustrating that it was seemingly impossible to accurately display interannual seasonal fluctuations on the same graph with a simplified x-axis using the Line Chart option. 

HG_16159_0-1744030494426.png

 

 

 

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"name": "dataset"},
  "mark": "line",
  //"mark": "area",
  "encoding": {
    "x": {
      "field": "DOY",
      "type": "quantitative",
      "axis": {
        "values": [1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335],
        "labelExpr": "timeFormat(toDate(datum.value * 86400000), '%b')",
        "title": "Month"
      }
    },
    "y": {
      "field": "Average of SI_density",
      "type": "quantitative",
      "axis": {
        "title": "Mean density (1000m-3)"
      }
    },
    "color": {
      "field": "Year",
      "type": "nominal",
      "title": "Year"
    },
    "tooltip": [
      {"field": "Year", "type": "nominal", "title": "Year"},
      {"field": "Formatted_Month", "type": "quantitative", "title": "Date"},
      {"field": "Average of SI_density", "type": "quantitative", "title": "Count"}
    ]
  }
}

 

View solution in original post

9 REPLIES 9
HG_16159
New Member

We solved this issue by converting our graph to a Denebe object, with the code below. While I lost the slider functionality, I retained the bulk of the functionality in the graph and can continue to filter the data based off location & year. It's frustrating that it was seemingly impossible to accurately display interannual seasonal fluctuations on the same graph with a simplified x-axis using the Line Chart option. 

HG_16159_0-1744030494426.png

 

 

 

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"name": "dataset"},
  "mark": "line",
  //"mark": "area",
  "encoding": {
    "x": {
      "field": "DOY",
      "type": "quantitative",
      "axis": {
        "values": [1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335],
        "labelExpr": "timeFormat(toDate(datum.value * 86400000), '%b')",
        "title": "Month"
      }
    },
    "y": {
      "field": "Average of SI_density",
      "type": "quantitative",
      "axis": {
        "title": "Mean density (1000m-3)"
      }
    },
    "color": {
      "field": "Year",
      "type": "nominal",
      "title": "Year"
    },
    "tooltip": [
      {"field": "Year", "type": "nominal", "title": "Year"},
      {"field": "Formatted_Month", "type": "quantitative", "title": "Date"},
      {"field": "Average of SI_density", "type": "quantitative", "title": "Count"}
    ]
  }
}

 

v-veshwara-msft
Community Support
Community Support

Hi @HG_16159 ,

Just checking in again as we haven’t heard back from you. If the provided solutions addressed your issue, kindly mark the helpful reply as the Accepted Solution to assist others with similar queries.

If your issue is still unresolved or you need further help, feel free to reach out.
Thank you.

v-veshwara-msft
Community Support
Community Support

Hi @HG_16159 ,

Following up again to check if your query has been resolved. If so, please consider marking the helpful response as the Accepted Solution to assist others facing similar issues. If you still need further assistance, please reach out.

Thank you!

v-veshwara-msft
Community Support
Community Support

Hi @HG_16159 ,

Thank you for being a part of the Microsoft Fabric Community.

Thanks, @lbendlin , for your valuable response.

 

Just following up to check if your query has been resolved. If so, please consider marking the helpful response as the Accepted Solution to assist others facing similar issues. If you still need further assistance, please reach out.

Thank you!

 

HG_16159
New Member

Thank you for your response and working on this. Since the 'trick' is to put the same year for all years on the x-axis label, there's no way to display it full extended without having the year displayed as well? That seems like an odd flaw for the program to have. I noticed in the file that there is no date hierarchy for the new column to help "force" the x-axis labels. Is this because there are not unique values throughout the column? 

I noticed in the file that there is no date hierarchy for the new column to help "force" the x-axis labels. 

Date hierarchies are generally useless (personal biased opinionated statement).  The Line chart visual is automatically rendering the x axis labels according to the available space and the data range your user looks at if that is fed by a date value.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

@lbendlin Apologies, data has been added. 

Your sample data is not very representative but here is a first stab at how to handle this.

 

lbendlin_0-1741401774928.png

The dynamic X axis unfortunately also means that you cannot influence the labels, so fully extended the zoom sliders will expose the trickery.

 

lbendlin_1-1741401846392.png

 

 

lbendlin_2-1741401868807.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.