Showing posts with label Power Query. Show all posts
Showing posts with label Power Query. Show all posts

Tuesday, January 28, 2025

Date and Time Functions in Power Query

Time Function

Introduction to Date and Time Functions in Power Query

Welcome to our beginner's guide on Date and Time Functions in Power Query! If you're just starting out with Power Query and want to learn how to handle date and time data effectively, you're in the right place. In this post, we'll explore some fundamental date and time functions that will help you perform essential calculations and transformations. Whether you need to add or subtract dates, calculate durations, or format date and time values, these functions will make your data manipulation tasks much easier. Let's get started and unlock the power of date and time functions in Power Query!

Tutorial: Using Date and Time Functions in Power Query

Example 1: Adding Days to a Date

One common task is adding a specific number of days to a date. Let's say you have a column with order dates, and you want to calculate the delivery date by adding 7 days to each order date.

Step-by-Step Guide:

  1. Load Your Data: Import your data into Power Query.
  2. Select the Column: Click on the column containing the order dates.
  3. Add Custom Column: Go to the "Add Column" tab and click on "Custom Column."
  4. Enter Formula: In the formula box, enter the following formula to add 7 days to the order date:
    = Date.AddDays([Order Date], 7)
    
  5. Name the Column: Give your new column a name, such as "Delivery Date," and click "OK."

Example Data:

Order Date
2025-01-01
2025-01-15

Result:

Order Date | Delivery Date
2025-01-01 | 2025-01-08
2025-01-15 | 2025-01-22

Example 2: Subtracting Time from a DateTime

Another useful function is subtracting time from a DateTime value. Suppose you have a column with event start times, and you want to calculate the preparation start time by subtracting 30 minutes from each event start time.

Step-by-Step Guide:

  1. Load Your Data: Import your data into Power Query.
  2. Select the Column: Click on the column containing the event start times.
  3. Add Custom Column: Go to the "Add Column" tab and click on "Custom Column."
  4. Enter Formula: In the formula box, enter the following formula to subtract 30 minutes from the event start time:
    = DateTime.AddMinutes([Event Start Time], -30)
    
  5. Name the Column: Give your new column a name, such as "Preparation Start Time," and click "OK."

Example Data:

Event Start Time
2025-01-01 10:00 AM
2025-01-15 02:00 PM

Result:

Event Start Time     | Preparation Start Time
2025-01-01 10:00 AM  | 2025-01-01 09:30 AM
2025-01-15 02:00 PM  | 2025-01-15 01:30 PM

Conclusion

By mastering these basic date and time functions, you'll be well-equipped to handle a variety of data transformation tasks in Power Query. Adding and subtracting dates and times are fundamental skills that will greatly enhance your data manipulation capabilities. Stay tuned for more tutorials and tips to help you become a Power Query pro!

Feel free to ask if you have any questions or need further assistance with Power Query!

Text Functions in Power Query


Introduction to Text Functions in Power Query

Welcome to our beginner's guide on Text Functions in Power Query! If you're new to Power Query and looking to enhance your data transformation skills, you've come to the right place. In this post, we'll explore some essential text functions that will help you clean, format, and manipulate text data with ease. Whether you're dealing with messy data or simply want to streamline your data preparation process, mastering these text functions will be a game-changer. Let's dive in and discover how to use Text.Split and Text.Combine to make your data work for you!

Tutorial: Using Text Functions in Power Query

Example 1: Splitting Text

One of the most common tasks in data transformation is splitting text into separate columns. Let's say you have a column with full names, and you want to split them into first and last names.

Step-by-Step Guide:

  1. Load Your Data: Import your data into Power Query.
  2. Select the Column: Click on the column containing the full names.
  3. Split Column by Delimiter: Go to the "Home" tab, click on "Split Column," and choose "By Delimiter."
  4. Choose Delimiter: Select the space as the delimiter and click "OK."

Example Data:

Full Name
John Doe
Jane Smith

Result:

First Name | Last Name
John       | Doe
Jane       | Smith

Example 2: Concatenating Text

Concatenating text is another powerful function that allows you to combine multiple columns into one. Let's say you have separate columns for first and last names, and you want to create a full name column.

Step-by-Step Guide:

  1. Load Your Data: Import your data into Power Query.
  2. Add Custom Column: Go to the "Add Column" tab and click on "Custom Column."
  3. Enter Formula: In the formula box, enter the following formula to concatenate the first and last names:
    = [First Name] & " " & [Last Name]
    
  4. Name the Column: Give your new column a name, such as "Full Name," and click "OK."

Example Data:

First Name | Last Name
John       | Doe
Jane       | Smith

Result:

Full Name
John Doe
Jane Smith

Conclusion

By mastering these basic text functions, you'll be well on your way to becoming proficient in Power Query. Splitting and concatenating text are fundamental skills that will significantly improve your data transformation capabilities. Stay tuned for more tutorials and tips to help you harness the full power of Power Query!

Feel free to ask if you have any questions or need further assistance with Power Query!