Time.FromText

D

T

The M Code Behind the Power Query M function Time.FromText

Understanding the Time.FromText Function

The Time.FromText function is a built-in Power Query function that allows users to convert text strings into time values. The function takes a single argument, which is the text string that contains the time data. The function then applies a series of transformations to the text string to extract the relevant time data, and returns a time value that can be used in calculations and analysis.

The Time.FromText function is particularly useful for working with time data that is stored in non-standard formats, or that needs to be extracted from other data sources. For example, if you have a dataset that contains time data in a variety of formats, the Time.FromText function can be used to standardize the data and convert it into a consistent format.

The M Code Behind the Time.FromText Function

The Time.FromText function is based on a series of M code transformations that are applied to the input text string. These transformations are designed to extract the relevant time data from the input string, and convert it into a time value that can be used for analysis.

The first step in the Time.FromText function is to extract the hour, minute and second values from the input text string. This is done using a series of text manipulation functions, which extract the relevant substrings from the input string. Once the hour, minute and second values have been extracted, they are converted into decimal values, and added together to create a time value.

The Time.FromText function also includes a number of error-handling features, which ensure that the function returns a valid time value even if the input text string contains errors or is in an unexpected format. For example, if the input string contains a time value that is greater than 24 hours, the function will automatically adjust the time value to the correct format.

Using the Time.FromText Function

The Time.FromText function can be used in a variety of ways to extract and manipulate time data. For example, the function can be used to convert time data from a variety of formats into a consistent format that can be used for analysis. The function can also be used to extract time data from other data sources, such as text files or databases.

To use the Time.FromText function, simply pass the input text string as a parameter to the function. The function will then apply the relevant transformations and return a time value that can be used for analysis. The time value can be used in calculations and analysis just like any other time value, and can be formatted and displayed in a variety of ways.

The Time.FromText function is a powerful tool for working with time data in Power Query. By understanding the M code behind the function, users can gain a deeper understanding of how the function works, and how it can be used to extract and manipulate time data. Whether you are working with time data in a variety of formats, or need to extract time data from other data sources, the Time.FromText function can help you standardize and convert your time data into a format that can be used for analysis.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)