• Home
  • About Us
  • Contact Us
  • Privacy Policy
  • Special Offers
Business Intelligence Info
  • Business Intelligence
    • BI News and Info
    • Big Data
    • Mobile and Cloud
    • Self-Service BI
  • CRM
    • CRM News and Info
    • InfusionSoft
    • Microsoft Dynamics CRM
    • NetSuite
    • OnContact
    • Salesforce
    • Workbooks
  • Data Mining
    • Pentaho
    • Sisense
    • Tableau
    • TIBCO Spotfire
  • Data Warehousing
    • DWH News and Info
    • IBM DB2
    • Microsoft SQL Server
    • Oracle
    • Teradata
  • Predictive Analytics
    • FICO
    • KNIME
    • Mathematica
    • Matlab
    • Minitab
    • RapidMiner
    • Revolution
    • SAP
    • SAS/SPSS
  • Humor

Guy in a Cube – How to expand a list of records in a query

March 8, 2016   Self-Service BI

This post will look at two different approaches for expanding a record from a list using Power BI and a bit of M syntax. In our specific case, a customer wanted to pull data from a record that was listed in the table output of a SharePoint list. We’re going to focus on the FieldValuesAsText column from that list, but the following would work with any field that was showing Record as the result.

If you click on Record, you see just a list of the fields for that one record. However, we want the values for every record as a table.

From the UI, you can select Drill Down > To Table.

Here is the syntax that was generated from the above steps. It makes use of the Table.FromList function and then uses the Table.ExpandRecordColumn function.

let
    Source = SharePoint.Tables(“
https://guyinacube.sharepoint.com”, [ApiVersion = 15]),
    #”920f5562-bfc9-4cf0-8c61-402745fe7f06″ = Source{[Id=”920f5562-bfc9-4cf0-8c61-402745fe7f06″]}[Items],
    FieldValuesAsText = #”920f5562-bfc9-4cf0-8c61-402745fe7f06″[FieldValuesAsText],
    #”Converted to Table” = Table.FromList(FieldValuesAsText, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #”Expanded Column1″ = Table.ExpandRecordColumn(#”Converted to Table”, “Column1″, {“ContentTypeId”, “Title”, “OData__ModerationComments”, “File_x0020_Type”, “OData__x0069_kc3″, “jjbh”, “m57j”, “ID”, “Modified”, “Created”, “Author”, “Editor”, “OData__HasCopyDestinations”, “OData__CopySource”, “owshiddenversion”, “WorkflowVersion”, “OData__UIVersion”, “OData__UIVersionString”, “Attachments”, “OData__ModerationStatus”, “InstanceID”, “Order”, “GUID”, “WorkflowInstanceID”, “FileRef”, “FileDirRef”, “Last_x0020_Modified”, “Created_x0020_Date”, “FSObjType”, “SortBehavior”, “FileLeafRef”, “UniqueId”, “SyncClientId”, “ProgId”, “ScopeId”, “MetaInfo”, “OData__Level”, “OData__IsCurrentVersion”, “ItemChildCount”, “FolderChildCount”, “Restricted”, “OriginatorId”, “AppAuthor”, “AppEditor”, “SMTotalSize”, “SMLastModifiedDate”, “SMTotalFileStreamSize”, “SMTotalFileCount”}, {“Column1.ContentTypeId”, “Column1.Title”, “Column1.OData__ModerationComments”, “Column1.File_x0020_Type”, “Column1.OData__x0069_kc3″, “Column1.jjbh”, “Column1.m57j”, “Column1.ID”, “Column1.Modified”, “Column1.Created”, “Column1.Author”, “Column1.Editor”, “Column1.OData__HasCopyDestinations”, “Column1.OData__CopySource”, “Column1.owshiddenversion”, “Column1.WorkflowVersion”, “Column1.OData__UIVersion”, “Column1.OData__UIVersionString”, “Column1.Attachments”, “Column1.OData__ModerationStatus”, “Column1.InstanceID”, “Column1.Order”, “Column1.GUID”, “Column1.WorkflowInstanceID”, “Column1.FileRef”, “Column1.FileDirRef”, “Column1.Last_x0020_Modified”, “Column1.Created_x0020_Date”, “Column1.FSObjType”, “Column1.SortBehavior”, “Column1.FileLeafRef”, “Column1.UniqueId”, “Column1.SyncClientId”, “Column1.ProgId”, “Column1.ScopeId”, “Column1.MetaInfo”, “Column1.OData__Level”, “Column1.OData__IsCurrentVersion”, “Column1.ItemChildCount”, “Column1.FolderChildCount”, “Column1.Restricted”, “Column1.OriginatorId”, “Column1.AppAuthor”, “Column1.AppEditor”, “Column1.SMTotalSize”, “Column1.SMLastModifiedDate”, “Column1.SMTotalFileStreamSize”, “Column1.SMTotalFileCount”})
in
    #”Expanded Column1″

If you want to do this with M syntax, you can use the Table.FromRecords function. The FromRecords function takes a set of records and converts it to a table. At that point, you can remove unwanted to columns and continue to mash up your data.

This entry passed through the Full-Text RSS service – if this is your content and you’re reading it on someone else’s site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

Microsoft Power BI Blog | Microsoft Power BI

Cube, expand, List, query, records
  • Recent Posts

    • Export with large E instead of small e
    • You’ll be back
    • Building AI for the Global South
    • Dapper Duo
    • AI Weekly: These researchers are improving AI’s ability to understand different accents
  • Categories

  • Archives

    • March 2021
    • February 2021
    • January 2021
    • December 2020
    • November 2020
    • October 2020
    • September 2020
    • August 2020
    • July 2020
    • June 2020
    • May 2020
    • April 2020
    • March 2020
    • February 2020
    • January 2020
    • December 2019
    • November 2019
    • October 2019
    • September 2019
    • August 2019
    • July 2019
    • June 2019
    • May 2019
    • April 2019
    • March 2019
    • February 2019
    • January 2019
    • December 2018
    • November 2018
    • October 2018
    • September 2018
    • August 2018
    • July 2018
    • June 2018
    • May 2018
    • April 2018
    • March 2018
    • February 2018
    • January 2018
    • December 2017
    • November 2017
    • October 2017
    • September 2017
    • August 2017
    • July 2017
    • June 2017
    • May 2017
    • April 2017
    • March 2017
    • February 2017
    • January 2017
    • December 2016
    • November 2016
    • October 2016
    • September 2016
    • August 2016
    • July 2016
    • June 2016
    • May 2016
    • April 2016
    • March 2016
    • February 2016
    • January 2016
    • December 2015
    • November 2015
    • October 2015
    • September 2015
    • August 2015
    • July 2015
    • June 2015
    • May 2015
    • April 2015
    • March 2015
    • February 2015
    • January 2015
    • December 2014
    • November 2014
© 2021 Business Intelligence Info
Power BI Training | G Com Solutions Limited