Forum Discussion
Getting SharePoint List items with full history version?
How do you expand this function to get the complete version history for all rows in a column?
Hi tdaskalakis,
here is an short example how to use the function:
1) Add an Query to your list where you want to see the version history:
let
Source = SharePoint.Tables("https://<yourDomain>.sharepoint.com/sites/<YourSPSite>", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Title] = "SampleList")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Items", "Title"}),
#"Expanded Items" = Table.ExpandTableColumn(#"Removed Other Columns", "Items", {"Id"}, {"Items.Id"})
in
#"Expanded Items"2) Invoke the Custom Function "GetVersionHistoryFromSharePointList" (from post above)
3.) after the invoke your table will have the column version which contains an table which contains a table per version of the item.
4) expand the Table.
5) now you have all possible items in a list, now you can further expand specific columns as you need.
Example code after those steps:
let
Source = SharePoint.Tables("<Your SP Site Link>", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Title] = "SampleList")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Items", "Title"}),
#"Expanded Items" = Table.ExpandTableColumn(#"Removed Other Columns", "Items", {"Id"}, {"Items.Id"}),
#"Invoked Custom Function" = Table.AddColumn(#"Expanded Items", "Versions", each GetVersionHistoryFromSharePointList([Title], "<Your SharePoint Site>", [Items.Id])),
#"Expanded Versions" = Table.ExpandTableColumn(#"Invoked Custom Function", "Versions", {"properties"}, {"Versions.properties"}),
#"Expanded Versions.properties" = Table.ExpandTableColumn(#"Expanded Versions", "Versions.properties", {"IsCurrentVersion", "VersionId", "VersionLabel", "Title", "ExampleText"}, {"Versions.properties.IsCurrentVersion", "Versions.properties.VersionId", "Versions.properties.VersionLabel", "Versions.properties.Title", "Versions.properties.ExampleText"})
in
#"Expanded Versions.properties"- Anonymous6 years agoNot applicable
Awsome! You made my day. Thanks a lot. 🙂
- rantingdemon5 years agoNew Member
Great post, thank you very much!
- devhack5 years agoNew Member
This is great by the way, but for me it errors out when publish to Power BI service do to a query being called inside another query.