Search code examples
powerbipowerbi-desktoppowerbi-custom-visuals

Power BI X axis issue with days and hours


I'm new in Power BI and I would like to a create a line chart, with Selected Days and Hours on X axis, and the sum of values on Y axis in a selected Year. For example:

Here is the chart

As you can see I could do it, but with a scrollbar. I can't change the X axis type to continous because days (Monday, Tuesday etc.) are string. So I made a column with integers (like 1 is Monday, 7 is Sunday etc.). But it doesn't work either.

I would like to see the whole chart on page without scrollbar.

Let me know if it is possible, thank you!


Solution

  • In order to use a "continuous" X-axis you need to have a numeric column, in your case, even if you replace the "day name" with its corresponding number the value will be a string ie: "Saturday 11" → "6 11", also check the current data type of the column, maybe you just need to set it as number.

    Now let's say you make a meaningful number to represent your data and use a continuous X-axis, you won't have a scrollbar anymore, but you also won't be able to see all the values of the X-axis (you might see a value label every 5-10-20 values), and there is also the sorting to take into consideration.

    About the X-axis sorting, as of now, it looks totally random to me. Since the chart context is given by "year", to have a meaningful sorting of your dates you need at least a sorting key that represent Month and Day, if you want to use it in the axis itself as a number it should be in the format "MMDD"