Dax Function: DATEVALUE

Category: Date and Time Functions

The DATEVALUE function in Power BI is a DAX function that converts a date represented as text into a date in datetime format. It ensures proper handling of date strings and allows them to be used in calculations and visualizations.

Purpose

To transform text-based date representations into a datetime format for seamless analysis.

Type of Calculations

Performs data type conversions specifically for dates.

Practical Use Cases

Commonly used for cleaning data from non-standardized or external sources where dates are stored as text.

				
					DATEVALUE(date_text)
				
			
ParameterTypeDescription
date_textStringA text string representing a date in an acceptable format (e.g., MM/DD/YYYY, DD/MM/YYYY). The function relies on locale settings for interpretation.

How Does DATEVALUE Dax Function Works

The DATEVALUE function works as follows:

  1. It interprets the text string provided in date_text based on the system’s locale and date settings.
  2. Converts the string into a datetime value.
  3. Returns the converted datetime value or generates an error if the string format is invalid.

For example:

  • DATEVALUE("01/25/2025") returns 25 January 2025 12:00:00 AM.

What Does It Return?

  • Type: Datetime.
  • Meaning: Returns a datetime value corresponding to the input date_text. If the input contains only a date without a time component, the time defaults to 12:00:00 AM.

When Should We Use It?

  • Calculating Durations: Determine how long a project, t
  • Data Cleaning: Convert non-datetime data types into usable datetime values for analysis.
  • Interoperability: Handle data imported from external sources with inconsistent formats.
  • Dynamic Calculations: Enable text-based date fields to interact with other datetime functions (e.g., DATEDIFF, NOW).

Examples

Basic Usage

Convert a date string into a datetime value:

				
					DATEVALUE("02/10/2025")
				
			

Returns: 10 February 2025 12:00:00 AM.

Column Usage:

Transform a column of text-based dates in a table:

				
					NewDateColumn = DATEVALUE(Table[DateText])
				
			

For each row in the DateText column, the function converts the text into a datetime value.

Advanced Usage

Combine with logical conditions to process data dynamically:

				
					IF(DATEVALUE([DateText]) > TODAY(), "Future Date", "Past Date")
				
			

Labels dates as “Future Date” or “Past Date” based on whether they occur after today.

Tips and Tricks

  • Input Validation: Ensure date_text strings are in a recognizable format, matching the system’s locale.
  • Default Time: Remember that the function sets the time to 12:00:00 AM for dates without a time component.
  • Error Handling: Use error-handling functions like IFERROR to handle invalid date strings gracefully.

Potential Pitfalls

  • Locale Dependency: Misinterpretation of dates may occur if the text format conflicts with locale settings (e.g., MM/DD/YYYY vs. DD/MM/YYYY).
  • Invalid Strings: Non-date strings or unrecognizable formats will result in errors.

Performance Impact of DATEVALUE DAX Function:

  • Large Datasets: For tables with numerous rows of text-based dates, pre-transforming the data in the source system or Power Query may improve performance.
  • Error Handling: Use IFERROR or validation steps to manage potential issues with invalid formats.

Related Functions You Might Need

  • DATE: Constructs a datetime value from year, month, and day components.
  • TIMEVALUE: Converts a time in text format into a datetime value.
  • VALUE: Converts text to a number or datetime, depending on context.
  • FORMAT: Formats dates or other data types into strings.

Want to Learn More?
For more information, check out the official Microsoft documentation for DATEVALUE. You can also experiment with this function in your Power BI reports to explore its capabilities.

Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.

1. What does the DATEVALUE function do in Power BI?

The DATEVALUE function converts a text-based date into a datetime format that Power BI can use for calculations.

2. What happens if the text format doesn't match the locale?

If the date_text format conflicts with the system’s locale settings, the function may return errors or incorrect values.

3. Does DATEVALUE add a time component to the date?

If the input text includes only a date, the function sets the time to 12:00:00 AM.

4. Can DATEVALUE handle international date formats?

Yes, but it relies on the system’s locale settings to interpret the format correctly.

 

5. How to handle errors with invalid date strings in DATEVALUE?

Use the IFERROR function to return a default value or message when DATEVALUE encounters invalid inputs.

Established in 2020, Lets Viz Technologies provides a full range of high-quality data analysis and data visualization services. We are also an authorized Zoho Partner.

 

Contact

WeWork Berger Delhi One, C-001/A2, Sector 16B, Noida, Uttar Pradesh 201301

0124-502-5592
info@lets-viz.com

We are Social

Trust Pilot Reviews