After I’d written it – I realised my last post was perhaps not the most useful for those who really don’t care about the how but want to know what to do to use it. So this will follow the same deal as with the last post (over a year and a half ago!! WOW!).
Video version below if you want it:
The Setup Steps
First – we’ve got to install PowerBI – now, I didn’t sign up for an account, but downloaded it from the PowerBI website, and installing was simple and quick.
We also need to have Neo4j running, and you can use Community or Enterprise, it matters not – and we’ll want to put the ‘Movies’ dataset in there, so run your instance, and execute:
:play movies
Add the Data Connector to Power BI
- First – download the connector from the releases page (or build it yourself in VS) – you want the
Neo4j.mez
file.
Version 1: https://github.com/cskardon/Neo4jDataConnectorForPowerBi/releases/tag/1.0.0
- PowerBI looks for custom connectors in the
<USER>\Documents\Power BI Desktop\Custom Connectors
folder, which if it doesn’t exist – you’ll need to create. Once you have that folder, copy theNeo4j.mez
connector there.
- Nearly there – we just need to allow PowerBI to load the connector now – so, start up PowerBI and go to the Options dialog:
Once there, select the ‘Security’ option, and then under the Data Extensions header select the option allowing you to load any extension without validation or warning:
You’ll have to restart PowerBI to get the connector to be picked up – so go ahead and do that now!
Lets Get Some Data!
Now – I know a lot of you will have been excited by the Pie Chart from the last post – now you can create your own!
With a new instance of PowerBI running, let’s select ‘Get Data’
We can now either search for ‘Neo4j’ or look in the ‘Database’ types:
Select Neo4j
then press ‘Connect’ – aaaaand a warning!
Read it, ignore it – it’s up to you – but this is just to let you know that it’s still in Beta (I mean it’s only had one release so far!) Continue if you’re happy to.
Now you’re given the boxes to enter your Cypher and connection information – the text box for the Cypher field is a single line (ugh) – so if it’s a complicated query – you’re probably best of writing it in Sublime or similar (maybe even Notepad!?!). In this case, we can go simple:
MATCH (m:Movie) RETURN m;
Now, the other settings, if you’re running default settings – you can leave these, but obviously if you need to connect to https
instead of http
change it in the scheme
setting. I’ve filled in my display with the defaults:
When you press OK, you get the Login dialog, _if _you are anonymously connecting, then select Anonymous, else – fill in your username / password.
Press ‘Connect’, and PowerBI will connect to your DB and return you back a list of ‘Record’:
We’ll want to ‘Edit’ this, so press ‘Edit’!
When the Power Query Editor opens press the expand column button at the top of the ‘m’ column:
Ooooooh, ‘tagline’, ‘title’ and ‘released’ — our movie properties! For this, I would turn off the ‘use original column name as prefix’ checkbox, leave them all selected and press OK.
Data!!
Now, let’s ‘Close & Apply’ our query – NB – if you look in the ‘Applied Steps’ section, you can see we only have 2 steps, ‘Source’ and ‘Expanded m’
Whilst PowerBI applies it just think of the Pie charts that lie ahead of us:
When that dialog disappears, we’re good to go! On the right you’ll see a ‘Fields’ section, and you should see something like this:
So, the moment we’ve all waited for…
Let’s Pie Chart
Select ‘Pie Chart’ from the Visualizations section:
Once it’s in your display – select it and drag the ‘released’ field from the Query1
to the ‘details’ field, and then title to the ‘values’ field:
Your chart should look something like this now:
So let’s max size it, and mouse over it, now we can see:
But we can also drag ‘title’ on to the Tooltips field like so to get the First (or last) movie in that group:
What does a query look like under the covers?
Some of us like visual, some like code, the last time we tried this – our query was 20 lines long – our new query though – that’s just 5!
let Source = Neo4j.ExecuteCypher("MATCH (m:Movie) RETURN m;", "http", "localhost", 7474), #"Expanded m" = Table.ExpandRecordColumn(Source, "m", {"tagline", "title", "released"}, {"tagline", "title", "released"})in #"Expanded m"
Which is much nicer.
Hey hey! It’s Beta!
The Data Connector approach gives a much nicer way to query the database, it strips out a lot of the code we have to write, and hopefully makes the querying easier.
BUT – I am not a PowerBI expert – is this the right way to do this? Are there improvements? Some hardcoded queries we should have there? Let me know – do a PR – it’s all good!
Top comments (0)