List.ConformToPageReader

List.ConformToPageReader

D

The M Code Behind the Power Query M function List.ConformToPageReader

In this article, we will take a closer look at the List.ConformToPageReader M function, which is used to transform a list of records into a table that is suitable for display in a Power BI report.

Understanding the List.ConformToPageReader Function

The List.ConformToPageReader function is used to convert a list of records into a table that can be displayed in a Power BI report. This function takes two arguments: the list of records to be converted, and a function that provides information about the schema of the resulting table.

The first argument to the List.ConformToPageReader function is a list of records. Each record in the list represents a row in the resulting table. The records can have different fields, but they must have the same number of fields and the fields must be of the same data type.

The second argument to the function is a schema function. This function takes no arguments and returns a record that describes the schema of the resulting table. The record must have one field for each column in the table, and the name and data type of each field must match the corresponding field in the records that make up the list.

Example Usage of List.ConformToPageReader

To illustrate the usage of the List.ConformToPageReader function, consider the following example. Suppose we have a list of records that represent sales data for different products and regions. Each record has three fields: Product, Region, and SalesAmount.


[

[Product = “Product A”, Region = “North”, SalesAmount = 1000],

[Product = “Product A”, Region = “South”, SalesAmount = 2000],

[Product = “Product B”, Region = “North”, SalesAmount = 1500],

[Product = “Product B”, Region = “South”, SalesAmount = 2500]

]


To convert this list of records into a table, we can use the List.ConformToPageReader function as follows:


let

SalesData = [

[Product = “Product A”, Region = “North”, SalesAmount = 1000],

[Product = “Product A”, Region = “South”, SalesAmount = 2000],

[Product = “Product B”, Region = “North”, SalesAmount = 1500],

[Product = “Product B”, Region = “South”, SalesAmount = 2500]

],

Schema = () => [

Product = type text,

Region = type text,

SalesAmount = type number

],

SalesTable = Table.FromRecords(List.ConformToPageReader(SalesData, Schema))

in

SalesTable


The schema function in this example returns a record that describes the schema of the resulting table. The resulting table has three columns: Product, Region, and SalesAmount. The List.ConformToPageReader function converts the list of records into a table that has the same schema as the record returned by the schema function.

The List.ConformToPageReader M function is a powerful tool for transforming a list of records into a table that can be displayed in a Power BI report. This function takes a list of records and a schema function as its arguments, and returns a table that has the same schema as the record returned by the schema function. By using this function, users can easily transform and reshape their data in Power Query, and create compelling reports in Power BI.

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)

Copyright, G Com Solutions Ltd, 2024.
Tower Bridge Business Centre, 46-48 East Smithfield, London E1W 1AW
0800 998 9248   |   9:00 a.m. till 5:30 p.m.

Connect With Me: