When to use this Power Query pattern
Use this pattern when the same data preparation step needs to happen every time a file, table or report refreshes.
Syntax or pattern
(InputText as text) as text => Text.Upper(Text.Trim(InputText))Typical UI steps
- Open Power Query Editor.
- Select the relevant column or query.
- Apply the transformation from the ribbon or formula bar.
- Review the generated step.
- Check data types and row counts before loading.
5 practical examples
Use Function in a sales report
This example shows how to use Function when preparing a sales report.
(InputText as text) as text => Text.Upper(Text.Trim(InputText))Use this pattern when the sales report needs a repeatable transformation instead of manual cleanup.
Use Function in a customer list
This example shows how to use Function when preparing a customer list.
(InputText as text) as text => Text.Upper(Text.Trim(InputText))Use this pattern when the customer list needs a repeatable transformation instead of manual cleanup.
Use Function in a inventory export
This example shows how to use Function when preparing a inventory export.
(InputText as text) as text => Text.Upper(Text.Trim(InputText))Use this pattern when the inventory export needs a repeatable transformation instead of manual cleanup.
Use Function in a monthly dashboard
This example shows how to use Function when preparing a monthly dashboard.
(InputText as text) as text => Text.Upper(Text.Trim(InputText))Use this pattern when the monthly dashboard needs a repeatable transformation instead of manual cleanup.
Use Function in a operations tracker
This example shows how to use Function when preparing a operations tracker.
(InputText as text) as text => Text.Upper(Text.Trim(InputText))Use this pattern when the operations tracker needs a repeatable transformation instead of manual cleanup.
Common mistakes to avoid
- Hard-coding file paths or dates that should be parameters.
- Creating custom functions before the basic query is stable.
- Forgetting to test the function with several input values.
FAQ
When should I use Function in Power Query?
Use Function when the transformation should be repeatable every time the data refreshes.
Can I do Function from the Power Query interface?
Usually yes. The interface creates the M code for many common transformations, and you can adjust it in the formula bar or Advanced Editor.
Should I edit the M code manually?
Edit M manually when the interface cannot express the pattern clearly, or when you need reusable logic, parameters or cleaner step names.