top of page

Power BI Date Format (Various examples)


Making Sence Of Power BI Date Format
Making Sense Of Power BI Date Format

As IT Managers, it’s important to understand the different ways dates can be used in Power BI. Dates are handled as a data type; this knowledge enables you to combine comparisons of many varied types of data and produce succinct visuals that show trends, patterns and anomalies over time. By mastering how to effectively use date ranges in Power BI, you can create meaningful insights that would not otherwise surface. In this blog post we will explore how effective date handling can take your analytics capabilities to new heights and reveal powerful information from your datasets.


When you import data into Power BI, it will automatically detect and assign the data type for each column, including date columns. Once a date column is recognized, you can use it in various ways in your visualization, such as using it as a dimension on a chart's x-axis, grouping by year, quarter, month, or week, or filtering by a date range.


Power BI also has a built-in date hierarchy, which allows you to drill down and drill up through different levels of date granularity, such as year, quarter, month, and day.


Additionally, you can format the date to your desired format in the Modeling tab. It also has a time intelligence feature that allows you to perform time-based calculations, such as year-over-year, quarter-over-quarter, and more.


Power BI is a powerful tool for analyzing data. It provides a lot of flexibility in terms of date handling and granularity, as well as time-based calculations. If you're looking for an easy way to visualize and analyze your data,Power BI is definitely worth checking out.


What Are M and DAX In Power BI and How Do They Relate To Dates


Power BI Vs M

M and DAX are both languages used in Power BI to manipulate and analyze data. M (also known as Power Query) is used to extract, transform, and load data into Power BI. It allows you to connect to a variety of data sources, clean and reshape the data, and create custom calculations. M is a functional language, which means that it works by applying a series of transformations to the data, rather than using loops and conditional statements.


M (Power Query):

  • M is primarily used for data transformation and cleansing tasks.

  • M is a powerful and flexible language that allows you to shape and manipulate data in a variety of ways, including filtering, sorting, and grouping data, as well as creating new columns and calculating custom expressions.

  • M is also useful for creating complex queries that include joining, merging, and appending data from multiple sources.

  • Once you've transformed your data, it can be loaded into the Power BI data model for further analysis and visualization.

DAX (Data Analysis Expressions)

DAX (Data Analysis Expressions) is used to create calculations and aggregations within Power BI, such as creating calculated columns, tables, and measures. It is a formula language, similar to Excel formulas, that allows you to perform calculations on the data that is already loaded into Power BI. DAX is used to define calculated columns, calculated tables and Measures within Power BI.


DAX (Data Analysis Expressions):

  • DAX is primarily used for creating calculations and aggregations in the Power BI data model.

  • DAX is a formula language that uses a syntax similar to Excel formulas and can be used to create calculated columns, calculated tables, and measures.

  • DAX is also useful for creating complex calculations that include time intelligence, ranking, and filtering data.

  • DAX is used to define calculations and aggregations that can be used in visualizations and reports.

In conclusion, it is important to understand the difference between M and DAX in Power BI. M is used to shape and prepare data before it is loaded into Power BI, while DAX is used to perform calculations and create new values within Power BI once the data has been loaded. By understanding the role of each language, you can more effectively use Power BI to analyze your data.


How Do I Format A Date In DAX Power BI?

In DAX (Data Analysis Expressions) in Power BI, you can use the FORMAT function to format a date. The basic syntax of the function is: FORMAT(date_expression, format_string) date_expression is the column or expression that contains the date that you want to format. format_string is the format that you want to use to display the date. For example, you can use the format string "MM/dd/yyyy" to display the date as "01/25/2023".



You can also use the following date and time formats in the format_string:
  • "yyyy" for the year with century as a decimal number

  • "yy" for the year without century as a decimal number

  • "MMMM" for the full month name

  • "MMM" for the abbreviated month name

  • "MM" for the month as a decimal number

  • "M" for the month as a decimal number

  • "dddd" for the full weekday name

  • "ddd" for the abbreviated weekday name

  • "dd" for the day of the month as a decimal number

  • "d" for the day of the month as a decimal number

  • "HH" for the hour (24-hour clock) as a decimal number

  • "H" for the hour (24-hour clock) as a decimal number

  • "hh" for the hour (12-hour clock) as a decimal number

  • "h" for the hour (12-hour clock) as a decimal number

  • "mm" for the minute as a decimal number

  • "m" for the minute as a decimal number

  • "ss" for the second as a decimal number

  • "s" for the second as a decimal number

  • "AM/PM" to use the 12-hour clock and display "AM" or "PM"

M Code For Date Transformations

In Power BI, you can use the "M" language to write custom expressions to transform date formats. Here are the steps to use M code for date transformations in Power BI:

  • Open the Power Query Editor by clicking on the "Edit Queries" button in the Home tab.

  • Select the column that contains the date that you want to transform.

  • Click on the "Transform" tab, and then click on the "Format" button in the "Any Column" group.

  • In the "Format" dialog box, select "Custom" as the format option, and enter the M code expression that you want to use to transform the date format.

  • -For example, you can use the following M code expression to convert a date in the format "dd-MM-yyyy" to the format "MM-dd-yyyy": = Table.TransformColumnTypes(Source,{{"Column1", type date}}), Click "OK" to apply the transformation.



You can use the M code to transform the date format and also use other functions such as DateTime.ToText or DateTime.LocalNow and many others to manipulate dates.


Power BI Date Format Short Month Name

-In Power BI, you can format a date to display the short month name by using the "MMM" code in the custom format field. Here are the steps to format a date to display the short month name:

  • Select the column that contains the date, then right-click and choose "Format Column."

  • In the "Format" section, select "Custom" as the format option.

  • In the custom format field, enter "MMM" to display the short month name (e.g. "Jan" for January)

  • Click "OK" to apply the format.

  • Alternatively, you can use the "MMM" code in the DAX formula to have the short month name in the calculated column or measure.

  • For example, you can use the following DAX formula to create a calculated column with the short month name : =FORMAT(your_date_column,"MMM")

  • You can also use the same code in your visualization to have the short month name in the axis, tooltip or other visualization elements

Note that the format codes such as "MMM" are case sensitive, so make sure you use the correct capitalization when entering them in the custom format field.

case-sensitive

How Do You Change Date Format To MM DD YYYY In Power BI?

In Power BI, you can change the date format of a column to "MM DD YYYY" by using the FORMAT function in DAX (Data Analysis Expressions). Here are the steps:

  • Go to the Power Query Editor by clicking on "Edit Queries" in the "Home" tab.

  • Select the date column that you want to change the format for.

  • Click on the "Add Column" tab and then click on "Custom Column".

  • In the "New column name" field, enter a name for the new column.

  • In the "Custom column formula" field, enter the following formula: =FORMAT([Original Column], "MM DD YYYY")

  • Press OK.

This will create a new column with the date format "MM DD YYYY" based on the original column.


How do I Change The Date Format In Table In Power BI?


There are several ways to change the date format in a table in Power BI:

Using the "Format" function in a new column:

  • Create a new column in your Power BI dataset, and name it "Formatted Date".

  • In the formula bar, enter the following formula: = FORMAT(<date column>, "mm/dd/yyyy")

  • Replace <date column> with the name of the column that contains the date you want to format.

  • Press Enter to apply the formula and display the formatted date in the new column


Using the "Modeling" tab:

  • Select the column you want to change the format for and go to the "Modeling" tab.

  • Click on "Format" and select the format you want to use.

  • Right-clicking on the column header:Right-click on the column header of the table that you want to change the format for.

  • Select "Format Column" from the context menu.

  • In the "Format" section, select the format you want to use.


Using the "Visualizations" pane:

  • Select the table or visual that you want to change the format for.

  • Go to the "Visualizations" pane.

  • Under the "Format" section, select "More formats" -> "Custom" and then enter the format you want.

  • Note that these changes will only affect the table or visual you are working on, and will not change the format of the data in your underlying dataset.


Dealing With Inconsistent Date Formats

Dealing with inconsistent date formats in Power BI can be challenging, but there are several ways to handle it:


  • Use the "Parse" function: You can use the "Parse" function to convert a string value to a date/time value. This can be useful if the date format is consistent but not recognized by Power BI, for example, when the date is in the format "dd-MM-yyyy" instead of "MM-dd-yyyy".

  • Use the "Format" function: You can use the "Format" function to convert a date/time value to a string value in a specific format. This can be useful if the date format is consistent but not in the format you need, for example, when the date is in the format "MM-dd-yyyy" but you need it in the format "yyyy-MM-dd".

  • Use "Replace Values" feature: You can use the "Replace Values" feature to replace specific values in a column with new values. This can be useful when the date format is not consistent and you have a small number of inconsistent formats.

  • Use "M" Language: You can use the "M" language to write custom expressions to transform the date format. This can be useful when the date format is not consistent and you have a large number of inconsistent formats.

  • Combine the above methods: You can combine the above methods to tackle the inconsistent date formats.

  • It's important to note that, regardless of the method you choose, you'll need to do some data preparation and cleaning before you can use the data in Power BI. It's also a good practice to check and validate the data after you've cleaned it to ensure that it's accurate and in the format you need.


How Do I use The Date Hierarchy In Power BI

In Power BI, you can use the built-in date hierarchy to drill down and drill up through different levels of date granularity, such as year, quarter, month, and day. Here are the steps to use the built-in date hierarchy:


  • Select a visualization, such as a chart or a table, that you want to use the date hierarchy on.

  • Drag and drop a date column from your data model onto the visualization's x-axis, or into the "Values" or "Axis" field, depending on the visualization type.

  • Click on the "More options" button (represented by three dots) next to the date column on the x-axis, and select "New Group"

  • In the "New Group" dialog box, select the "By" field and choose the date column you want to group by.

  • Power BI will automatically create a new group for each level of the date hierarchy. You can then select the level you want to drill down to, for example, if you want to drill down to the month level, you can select the months group.

  • You can also click on the plus sign next to the date group to drill down to the next level, or the minus sign to drill up to the previous level.

  • You can also group your data by other levels like days, weeks, quarters or years. You can also format your date field to your desired format as well.

By using the built-in date hierarchy, you can quickly and easily drill down and drill up through different levels of date granularity, and analyze your data in a way that makes the most sense for your analysis.



Get in Touch

Thanks for submitting!

bottom of page