Forum Discussion
X-axis label formatting not responding in a Line chart with multiple series of time-series data
- 10 months ago
Hi _Matthew_ ,
this morning working on a line chart I remembered your posting and had an idea for a solution.
What do you think about this one:
Basic ideas are:
- Make the x-axis labels invisible
- Disable vertical grid lines
- Add 12 reference lines, each as a x-axis constant line for the beginning of a month
- Add some extra space to center the labels
Are you interested in the details?
Working on this, a second idea came to my mind: Adding a dummy line with zero values and use custom data labels to get the x-axis labels. But unfortunately all data field for custom labels are greyed out. Obviously Power BI doesn't allow custom labels if you have more than one series (resulting from more than one y-axis entries or a legend entry). So that would be only an option for exactly one line.
Correction:
Multiples lines are possible, only the legend entry has to be avoided. If its an option for you to have separate measures for every year, the following could be an option too:
(no manual adding of 12 reference lines and no manual correction of label positions)
Hi _Matthew_, maybe I'm missing the point, but I still believe that it should work. I used the following setup taken from one of my projects:
- A Calendar table with the Date column "Transaction Date", formatted as date
- MonthShort is the equivalent to your SeasonalityDate column. Format is text and it is defined as:
MonthShort = FORMAT('Calendar'[Transaction_Date], "mmm") - I started with a line chart. Transaction Date is assigned to x-axis, a sales measure to the y-axis
In this case x-axis is automatically defined as continuous and the type is date - Switching the x-axis to Year (defined as whole number) the type is still continuous
- Switching the x-axis to MonthShort something interesting happens. x-axis type and range are no longer available. Obviously the type has to be categorical now, so there is no choice. But the chart looks fine. The only thing you have to do is to care for proper sorting using something like a numerical month id for a "sort by"
What exactly does not work for you?
Let me take a guess:
In your last posting you wrote "the chart can no longer use the SeasonalityDate field for the X-axis." Did you try to use your "old" SeasonalityDate field? A crucial part of my solution is to you use the newly defined column as x-axis.
Thank you Hans-Georg_Puls , I did use the "newly defined column as x-axis." In your example above the data series as plotted also displays how once one converts to categorical data, it reduces the X-axis to the twelve months (at least in that example), just 12 data points covering the year. One X-axis data point for each X-axis category. That one-to-one relationship becomes a major limitation.
I am dealing with daily weather data, and consolidating it to monthly (from daily data) would not be acceptable for the sake of analysis. Categorical data will display with daily data, but the chart visual becomes so wide that it can't be seen reasonably without lots of horizontal scrolling. I did set it up once this way while experimenting. Unfortunately, it wasn't useful.
- Hans-Georg_Puls10 months ago
Super User
Ah, sorry, _Matthew_ , that was the point I missed. Thank you for your patient explanation.
- _Matthew_10 months agoRegular Visitor
PowerBI Please take a look at this thread. It seems that we have outlined a legitimate use case which isn't well supported in the current state of development. Thanks!
- Hans-Georg_Puls10 months ago
Super User
Hi _Matthew_ ,
this morning working on a line chart I remembered your posting and had an idea for a solution.
What do you think about this one:
Basic ideas are:
- Make the x-axis labels invisible
- Disable vertical grid lines
- Add 12 reference lines, each as a x-axis constant line for the beginning of a month
- Add some extra space to center the labels
Are you interested in the details?
Working on this, a second idea came to my mind: Adding a dummy line with zero values and use custom data labels to get the x-axis labels. But unfortunately all data field for custom labels are greyed out. Obviously Power BI doesn't allow custom labels if you have more than one series (resulting from more than one y-axis entries or a legend entry). So that would be only an option for exactly one line.
Correction:
Multiples lines are possible, only the legend entry has to be avoided. If its an option for you to have separate measures for every year, the following could be an option too:
(no manual adding of 12 reference lines and no manual correction of label positions)