Mastering Power BI: Remove Year in Chart Visual x-Axis but Sort by Month and Year
Image by Emlen - hkhazo.biz.id

Mastering Power BI: Remove Year in Chart Visual x-Axis but Sort by Month and Year

Posted on

Are you tired of cluttered and confusing chart visualizations in Power BI? Do you want to focus on the monthly trends while still maintaining the integrity of your data? Look no further! In this comprehensive guide, we’ll walk you through the steps to remove the year from the x-axis in a chart visual while still sorting by month and year.

Understanding the Challenge

By default, Power BI chart visuals display the year in the x-axis, which can make it difficult to analyze monthly trends. This is especially true when working with large datasets that span multiple years. Removing the year from the x-axis can help declutter the visualization and make it easier to identify patterns.

Prerequisites

  • Basic understanding of Power BI and its chart visuals
  • A dataset with a date column (e.g., Date, DateTime, etc.)
  • A chart visual (e.g., Column Chart, Line Chart, etc.) set up with the date column as the x-axis

Step 1: Create a New Calculated Column

To remove the year from the x-axis, we’ll create a new calculated column that extracts the month from the date column. This column will serve as our new x-axis.


Month Column = FORMAT('Table'[Date], "mmm")

In the formula above, we’re using the `FORMAT` function to format the `Date` column as a three-letter abbreviation for the month (e.g., “Jan”, “Feb”, etc.). Name this new column `Month Column`.

Step 2: Create a New Calculated Column for Sorting

To maintain the correct sorting order, we’ll create another calculated column that combines the year and month. This column will serve as our sorting column.


Sort Column = 'Table'[Date].[Year] & 'Table'[Date].[Month]

In the formula above, we’re using the `&` operator to concatenate the year and month of the `Date` column. This creates a unique value for each month-year combination (e.g., “202201”, “202202”, etc.). Name this new column `Sort Column`.

Step 3: Set Up the Chart Visual

Now that we have our new calculated columns, let’s set up the chart visual.

  1. Drag and drop the `Month Column` to the x-axis field in the chart visual.
  2. Drag and drop the `Sort Column` to the x-axis sort field in the chart visual.
  3. Click on the `Sort Column` field and select “Sort by column” > “Sort Column” to apply the sorting.
  4. Optional: You can format the x-axis to display the month names instead of the abbreviations by selecting the `Month Column` field and using the “Format” option.

Step 4: Remove the Year from the x-Axis

Finally, let’s remove the year from the x-axis. To do this, we’ll edit the x-axis properties.

  1. Click on the x-axis field in the chart visual to open the “Axis” pane.
  2. In the “Axis” pane, select the “Format” tab.
  3. Under “Label format”, select “Custom” and enter the following format code:

[= Month Column]

This format code tells Power BI to display only the month column values on the x-axis, removing the year.

Putting it all Together

With these steps, you should now have a chart visual that displays only the month on the x-axis, sorted by month and year. You can customize the appearance of the chart visual as needed, such as adding additional fields to the y-axis or modifying the chart type.

Before After

As shown in the example above, the original chart visual displays the year in the x-axis, making it difficult to analyze monthly trends. The modified chart visual, on the other hand, displays only the month on the x-axis, making it easier to identify patterns and trends.

Conclusion

By following these steps, you’ve successfully removed the year from the x-axis in your Power BI chart visual while still maintaining the correct sorting order by month and year. This technique can be applied to various types of chart visuals and datasets, giving you more flexibility and control over your data visualizations.

Remember to experiment with different formatting options and visualization types to customize your chart visuals to your needs. Happy Power BI-ing!

Additional Resources

Frequently Asked Question

Get ready to unlock the secrets of Power BI and master the art of creating stunning charts!

How do I remove the year from the x-axis in a Chart visual in Power BI?

To remove the year from the x-axis, you need to create a new column that extracts the month from the date field. You can do this by going to the Modeling tab > New Column > and using the formula `MONTHNAME(‘Table'[Date Column])`. Then, drag this new column to the x-axis and set the axis type to “Categorical”. Voilà! Your chart will now display only the month names.

How do I sort the months in the correct order (Jan to Dec) on the x-axis?

To sort the months in the correct order, you need to create a sort column. Go to the Modeling tab > New Column > and use the formula `MONTH(‘Table'[Date Column])`. Then, go to the Modeling tab > Sort by Column > and select the new sort column. This will sort your months in the correct order, from January to December.

Why do I need to create a new column to extract the month from the date field?

You need to create a new column to extract the month because Power BI doesn’t allow you to format the x-axis to display only the month name while still sorting by the full date. By creating a new column, you can control how the x-axis is displayed and sorted.

Can I use the “Format” option to remove the year from the x-axis?

No, the “Format” option won’t work in this case. The “Format” option only changes how the date is displayed, but it doesn’t allow you to remove the year from the x-axis. You need to create a new column to extract the month and sort by the full date to achieve the desired outcome.

Will this method work for other date fields, such as quarters or days?

Yes, this method can be applied to other date fields, such as quarters or days. You can use similar formulas to extract the quarter or day from the date field and sort by the full date. Just remember to adjust the formula and sorting column accordingly.