Power BI as of today doesn’t have inherit support to import SPSS file.
There are various ways you can import SPSS file in Power BI:
- Export SPSS file to Excel (with labels) and import Excel into Power BI
- Import using R – check here community blog for one of the ways https://community.powerbi.com/t5/Power-Query/Import-SPSS-file-into-Power-BI/td-p/43117
- Import using Python – using savReaderWriter library
We will discuss point #3 in detail.
1) Install and configure Python.
You will have to install pandas and matplotlib Python packages and enable Python script in Power BI. Check detailed steps on this official link.
2) Install savReaderWriter package.
The package requires spssio32.dll (Windows); in case you don’t have SPSS installed then do download SPSS IO module from here: https://www.ibm.com/support/pages/where-spss-io-module-windows-and-documentation or https://github.com/AArnott/SPSS.NET
pip install savReaderWriter
More details on the package: https://pypi.org/project/savReaderWriter/
3) Get data from SPSS using Python script
a. Power BI > Get data > Other > Python Script > Connect
b. Copy paste below code and replace the file name and path as per your needs
import pandas as pd
data = savReaderWriter.SavReader("d:\car_sales.sav", returnHeader=True, ioUtf8=True)
df = pd.DataFrame(data)
c. Click Ok
d. It will now connect to the SPSS file and extract data.
e. Click Transform data in order to edit data and especially use the first row as header
f. Click “Close and Apply” in Power query editor and now your data is ready for analysis/visualization
SavReader function has a lot more options. So in case you want to customize import then do check API document for details: https://pythonhosted.org/savReaderWriter/generated_api_documentation.html
Feel free to post your queries or suggestion below.