You’re wanting to preserve daily granularity in the line chart while controlling the density of x-axis labels. With core visuals, you’re limited by how the x-axis is handled. Categorical gives you full control over label frequency, but doesn’t respect time scaling. Continuous respects time scaling, but Power BI auto-fits labels and doesn’t allow you to set the density explicitly.
That lack of fine-grained control over tick/label density on a continuous axis is the core frustration here.
If you want full control, you can use Deneb with Vega-Lite. Here’s a template that keeps daily ticks but lets you control label rules with labelExpr
:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"name": "dataset"
},
"mark": {
"type": "line",
"point": false
},
"encoding": {
"x": {
"field": "Date",
"type": "temporal",
"axis": {
"title": "Date",
"tickCount": {
"interval": "day",
"step": 1
},
// five examples:
//
// show every 7 days:
//
// "labelExpr": "toNumber(timeFormat(datum.value, '%j')) % 7 === 0 ? timeFormat(datum.value, '%b %d') : ''",
//
// show only month boundaries:
//
// "labelExpr": "timeFormat(datum.value, '%d') === '01' ? timeFormat(datum.value, '%b %d') : ''",
//
// Every 7 days with an offset
//
// "labelExpr": "(toNumber(timeFormat(datum.value, '%j')) - 3 + 366) % 7 === 0 ? timeFormat(datum.value, '%b %d') : ''",
//
// mondays only:
//
// "labelExpr": "timeFormat(datum.value, '%u') === '1' ? timeFormat(datum.value, '%b %d') : ''",
//
// 1st and 15th of each month
//
"labelExpr": "(timeFormat(datum.value, '%d') === '01' || timeFormat(datum.value, '%d') === '15') ? timeFormat(datum.value, '%b %d') : ''",
"labelPadding": 4,
"labelOverlap": false,
"labelFontSize": 10
}
},
"y": {
"field": "Sales Amount",
"type": "quantitative",
"axis": {
"title": "Sales Amount"
}
}
}
}
I gave a few different examples that would produce charts like these:
1st and 15th:
Every monday:
Add a Deneb visual to your report, drop in the Date column from your date table and the Sales Amount measure, then paste in the script. I’ve also added it to your working PBIX for reference.
Is that what you were hoping to accomplish?
Custom X axis issue-DEH Solution.pbix (2.4 MB)