Power Query Table.ConformToPageReader: How to Use It
In this article
Table.ConformToPageReader is a Power Query M function that returns a table conforming to the schema expected by a page reader, typically used when you need to reshape a table so it can be read by a function that expects a specific page structure. In practice, it is a niche function that appears in custom connectors and advanced data extraction scenarios, and it is not available in the standard Power Query Editor interface. You use it by writing an M expression that calls Table.ConformToPageReader with the appropriate arguments, usually inside a custom connector or a manual query. To get started, you need Power Query in Excel, Power BI Desktop, or another host that supports M, and you need to understand the structure of the page reader you are targeting.
What You'll Need
- Power Query available in Excel (Data > Get & Transform Data), Power BI Desktop (Home > Transform data), or another host that supports M queries.
- Access to the Advanced Editor or the formula bar to write M code directly.
- A basic understanding of M functions and records, because Table.ConformToPageReader works with a table and a page reader function.
- Documentation or knowledge of the specific page reader you are using, since the function is designed to match its expected schema.
- For custom connectors, the Power Query SDK and a development environment if you are building a connector that uses this function.
Step-by-Step
- Open Power Query in your host application. In Excel, go to Data > Get & Transform Data > Launch Power Query Editor. In Power BI Desktop, go to Home > Transform data.
- Create a new blank query. In the Power Query Editor, go to Home > New Source > Other Sources > Blank Query. This gives you a query where you can write M code.
- Open the Advanced Editor. Go to Home > Advanced Editor. This is where you will write the M expression that calls Table.ConformToPageReader.
- Write the M expression. The function signature is Table.ConformToPageReader(table as table, pageReader as function) as table. You need to provide a table and a page reader function. For example, if you have a table named MyTable and a page reader function named MyPageReader, the expression would be: Table.ConformToPageReader(MyTable, MyPageReader). Replace these with your actual table and function names.
- Define the page reader function if you have not already. The page reader function is typically a custom function that takes a page and returns a table. You can define it in the same query or reference an existing function. For example: MyPageReader = (page as any) as table => ... . The exact implementation depends on your data source.
- Ensure the table argument is a table. If you are working with a list or a record, convert it to a table first using Table.FromList or Table.FromRecords. The function expects a table as its first argument.
- Check that the page reader function is compatible. The page reader must accept the structure of the table you are passing. If the table does not match the expected schema, the function may return an error or unexpected results. Review the documentation for your page reader to understand its requirements.
- Close the Advanced Editor and run the query. Click Done, then check the output in the Power Query Editor. If the function succeeds, you will see a table that conforms to the page reader's schema. If it fails, you will see an error message that can help you diagnose the issue.
- Load the result to your worksheet or data model if needed. Once the query returns the expected table, you can close and load it as you would any other Power Query query.
Common Mistakes
- Passing a list or record instead of a table. Table.ConformToPageReader requires a table as the first argument. Use Table.FromList or Table.FromRecords to convert your data first.
- Using a page reader function that does not match the table structure. The function is designed to conform the table to the page reader's expectations, but if the page reader is not compatible, you will get errors. Always verify the page reader's requirements.
- Forgetting to define the page reader function. If you reference a function that does not exist, you will get an error. Make sure the function is defined in the query or available in the environment.
- Assuming Table.ConformToPageReader is available in the standard Power Query Editor UI. It is not; you must write M code manually. Do not look for it in the ribbon or menus.
- Ignoring error messages. Power Query provides detailed error messages that can point to the exact problem, such as a type mismatch or missing function. Read them carefully.
Tips
- Use the formula bar to test small expressions before writing a full query. You can see the result immediately.
- If you are building a custom connector, refer to the Power Query SDK documentation for examples of Table.ConformToPageReader in context.
- Keep your page reader function simple and focused. It should only handle the transformation from a page to a table, not additional logic.
- Use the #shared keyword to browse available functions and see if Table.ConformToPageReader is available in your environment. It is part of the standard library but may not be exposed in all hosts.
- Test with a small sample table first to ensure the function works as expected before applying it to large datasets.
Troubleshooting
If you encounter an error, start by checking the arguments. Ensure the first argument is a table and the second is a function. If the error is about the function not being found, verify that the page reader function is defined and spelled correctly. If the error is about schema mismatch, review the page reader's expected input and adjust your table accordingly. If the function returns an empty table, check that the page reader is actually returning data. You can test the page reader separately by calling it with a sample page. If you are still stuck, consult the official Power Query documentation or community forums for examples. Remember that Table.ConformToPageReader is an advanced function and may not be necessary for most common data shaping tasks; consider whether a simpler approach using Table.TransformColumns or Table.AddColumn would achieve your goal.
Frequently Asked Questions
What is Table.ConformToPageReader used for?
It is used to conform a table to the schema expected by a page reader function, typically in custom connectors or advanced data extraction scenarios where data is read page by page.
Is Table.ConformToPageReader available in the Power Query Editor UI?
No, it is an M function that you must call manually through the Advanced Editor or formula bar. It does not appear as a button or menu option.
Can I use Table.ConformToPageReader in Excel and Power BI?
Yes, as long as the host supports Power Query M and the function is part of the standard library, which it is. However, it is rarely needed in everyday queries.
What happens if the page reader function is not compatible?
You will likely get an error or unexpected results. The function attempts to conform the table to the page reader's expected structure, but if the page reader cannot handle the table's schema, it will fail.
Do I need to define the page reader function myself?
Yes, you must provide a function that acts as the page reader. This is usually a custom function you write or one provided by a connector.
Is Table.ConformToPageReader the same as Table.FromRecords?
No, Table.FromRecords converts a list of records to a table, while Table.ConformToPageReader reshapes a table to match a page reader's schema. They serve different purposes.