Automatically select the period axis in Power BI with Field parameters
Smart date axis with Field parameters
A very clever trick to improve the user interface by adding an automatic period to the X axis of a Power BI visual. It selects the most optimal period to display based on the period of the date range chosen in the date slicer.
Inspired from Bas video from “How to Power BI “ YouTube channel , this tip allows to auto-change the axis of the period to Months/ Quarters/ Day regarding the month count picked from the date slicer.
Example: if the user selects a date range between 1 January 2022 and 31 March 2021, the date axis is set in months, if he selects a period between 1 January 2022 and 31 August 2022, the axis is set in quarters.
Below is the rule I used:
You can implement the logic that best suits your needs.
To configure this trick we need to:
Create a Field Parameters by adding the required date fields (Months, Quarter, Day in my example) =>it will create "period parameter order" for each field
Put it in the X_axis on the Power BI visual
Create a "Dynamic Period" measure to define the period to be displayed based on the number of months in the date range
Use that measure to filter the Field Parameter added in the visual (We can use the generated column "filed parameter order" to filter the Field parameter according to the month count)
Voila the result 😍😍
==>This dynamic selection has really saved my life by allowing me to get an optimal rendering of my Power BI visual which is not cluttered especially when I look at my data analysis over a long period.