Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Get versions from SharePoint

Hi guys,

 

There are other threads that contain this question, but I did not resolve the issue. So I'm here asking it again.

 

I need to get the versioning of my SharePoint list into Power BI. But the columns Versions has an error.

 

This is my current M code

 

let
    Source = SharePoint.Tables("https://<company>.sharepoint.com/sites/ca/<list>/", [ApiVersion = 15]),
    #"d121b816-bf85-4693-967a-2fe2f95407bd" = Source{[Id="d121b816-bf85-4693-967a-2fe2f95407bd"]}[Items],
    #"Renamed Columns" = Table.RenameColumns(#"d121b816-bf85-4693-967a-2fe2f95407bd",{{"ID", "ID.1"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"FileSystemObjectType", "Id", "ServerRedirectedEmbedUri", "ServerRedirectedEmbedUrl", "ContentTypeId", "Title", "ComplianceAssetId", "PredecessorsId", "PercentComplete", "AssignedToId", "AssignedToStringId", "TaskGroupId", "TaskGroupStringId", "DueDate", "RelatedItems", "WorkflowLink", "OffsiteParticipant", "OffsiteParticipantReason", "WorkflowOutcome", "WorkflowName", "Action Date", "Adverse Action Notic", "Request Date", "SBA #", "Disbursement Ins"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"StartDate", type datetime}, {"Created", type datetime}, {"Modified", type datetime}})
in
    #"Changed Type"

 

PBI COmmunity Versions Error.jpg

 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

I think it's not currently possible without some custom or third party integration.

You can try these two partial workarounds:

1. Export to excel

  • Use the Export to Excel option in the List section of the ribbon (make sure the list view you export includes a modified column - thanks T6J2E5).
  • Save the owssvr.iqy file and open with notepad
  • Copy just the URL from the file and paste it back into your browser, adding "&IncludeVersions=TRUE"
  • Save the XML file and open in Excel (or your favorite XML viewer), selecting the "As an XML table" open option.
  • You'll have to delete the first few columns and rows as they contain the schema data but other than that you should have all the version history (I suggest you add the Version column to the view). You can sort by the Modified column to get a chronological change log of the entire list.

Refer: sharepoint-list-version 

 

2. Export to csv using PowerShell

# ******* Variables Section ******************
#Define these variables
$WebURL="http://sharepoint.crescent.com/sites/Sales/"
$ListName ="Invoice"
$ReportFile = "D:\Invoice_VersionHistory.csv"
# *********************************************

#delete file if exists
If (Test-Path $ReportFile)
 {
 Remove-Item $ReportFile
 }

#Get the Web and List
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)

 #Check if list exists
 if($List -ne $null)
 {
  #Get all list items
  $ItemsColl = $List.Items

  #Write Report Header
  Add-Content -Path $ReportFile -Value "Item ID, Version Lable, Created by, Created at, Title"

  #Loop through each item
  foreach ($item in $ItemsColl)
  {
   #Iterate each version
      foreach($version in $item.Versions)
       {
    #Get the version content
    $VersionData = "$($item.id), $($version.VersionLabel), $($version.CreatedBy.User.DisplayName), $($version.Created), $($version['Title'])"
    #Write to report
    Add-Content -Path $ReportFile -Value $VersionData
   }
  }
 }
Write-Host "Version history has been exported successfully!"​

Refer: How to export version history of SharePoint list items using powershell

 

After exporting to excel / csv file, you can get this file in power bi desktop.

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
Joerg
Helper I
Helper I

I don't know where I did find this solution, but for me it works fine since years.

Query your list and then you can add a new column:
Xml.Tables(Web.Contents("https://=>your.sharepoint.com/sites=<",[RelativePath="/=>your subsite<=/_api/web/Lists/getbytitle(=>yourList<=)/items("&Text.From([Id])&")/versions"]))

v-yingjl
Community Support
Community Support

Hi @Anonymous ,

I think it's not currently possible without some custom or third party integration.

You can try these two partial workarounds:

1. Export to excel

  • Use the Export to Excel option in the List section of the ribbon (make sure the list view you export includes a modified column - thanks T6J2E5).
  • Save the owssvr.iqy file and open with notepad
  • Copy just the URL from the file and paste it back into your browser, adding "&IncludeVersions=TRUE"
  • Save the XML file and open in Excel (or your favorite XML viewer), selecting the "As an XML table" open option.
  • You'll have to delete the first few columns and rows as they contain the schema data but other than that you should have all the version history (I suggest you add the Version column to the view). You can sort by the Modified column to get a chronological change log of the entire list.

Refer: sharepoint-list-version 

 

2. Export to csv using PowerShell

# ******* Variables Section ******************
#Define these variables
$WebURL="http://sharepoint.crescent.com/sites/Sales/"
$ListName ="Invoice"
$ReportFile = "D:\Invoice_VersionHistory.csv"
# *********************************************

#delete file if exists
If (Test-Path $ReportFile)
 {
 Remove-Item $ReportFile
 }

#Get the Web and List
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)

 #Check if list exists
 if($List -ne $null)
 {
  #Get all list items
  $ItemsColl = $List.Items

  #Write Report Header
  Add-Content -Path $ReportFile -Value "Item ID, Version Lable, Created by, Created at, Title"

  #Loop through each item
  foreach ($item in $ItemsColl)
  {
   #Iterate each version
      foreach($version in $item.Versions)
       {
    #Get the version content
    $VersionData = "$($item.id), $($version.VersionLabel), $($version.CreatedBy.User.DisplayName), $($version.Created), $($version['Title'])"
    #Write to report
    Add-Content -Path $ReportFile -Value $VersionData
   }
  }
 }
Write-Host "Version history has been exported successfully!"​

Refer: How to export version history of SharePoint list items using powershell

 

After exporting to excel / csv file, you can get this file in power bi desktop.

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

  • Save the owssvr.iqy file and open with notepad - after doing this it's all in different language.  how can i change to english? 
pranit828
Community Champion
Community Champion

Hi @Anonymous 

 

Plaese check and fix the data type of the returned resultset or before loading it as a source.

This issue comes when the data type mismatches.

pranit828_0-1597360718246.png

 

Did I resolve your issue? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!!

 

Regards,
Pranit





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

@pranit828

garzamalan_0-1597361189194.png

How do I do that in my sharepoint list?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.