Tag Archives

47 Articles

Ultimate Time Based Calculations Cheat Sheet for DAX / Power BI (including Week based calculations)

Power BI provides great time intelligence features to calculate Year-to-date (YTD), Month-to-date (MTD) and Quarter-to-date (QTD) totals. There is no such thing as Week-to-date (WTD) or Period-to-date (PTD) where period could be any arbitrary period definition (I used two-month periods in my example below). If you want those, you will have to create the calculations yourself. I was inspired by this excellent blog post and created an ultimate time-intelligence calculations Power BI file. I used Matt Massons excellent date dimension generation script to generate the date table for my example.

Download the full Power BI file here or get just the DAX formulas. Enjoy!

Basic Measures

  • Total Amount:
  • Total Quantity:

     

Day Measures

  • Total Amount for Last Day (Yesterday)
  • Total Amount for same Day last Year
  • Variance of total Amount compared to Total Amount for Last Day
  • Variance % of total Amount compared to Total Amount for Last Day
  • Variance of total Amount compared to Total Amount for same Day last Year
  • Variance % of total Amount compared to Total Amount same Day last Year
  • Total Quantity for Last Day (Yesterday)
  • Total Quantity for same Day last Year
  • Variance of total Quantity compared to Total Quantity for Last Day
  • Variance % of total Quantity compared to Total Quantity for Last Day
  • Variance of total Quantity compared to total Quantity for same Day last Year
  • Variance % of total Quantity compared to total Quantity for same Day last Year

Week Measures

  • Total Amount Week To Date
  • Total Amount for Last Week
  • Total Amount for same Week Last Year
  • Variance of total Amount Week To Date compared to Total Amount for Last Week
  • Variance % of total Amount Week To Date compared to Total Amount for Last Week
  • Variance of total Amount Week to Date compared to Total Amount for same Week last Year
  • Variance % of total Amount Week to Date compared to Total Amount for same Week last Year
  • Total Quantity Week To Date
  • Total Quantity for same Week Last Year
  • Total Quantity for Last Week
  • Variance of total Quantity Week To Date compared to Total Quantity for Last Week
  • Variance % of total Quantity Week To Date compared to Total Quantity for Last Week

    /li>
  • Variance of total Quantity Week to Date compared to Total Quantity for same Week last Year

    /li>
  • Variance % of total Quantity Week to Date compared to Total Quantity for same Week last Year

Month Measures

  • Total Amount Month To Date
  • Total Amount for same Month Last Year
  • Total Amount for Last Month
  • Variance of total Amount Month To Date compared to Total Amount for Last Month
  • Variance % of total Amount Month To Date compared to Total Amount for Last Month
  • Variance of total Amount Month to Date compared to Total Amount for same Month last Year
  • Variance % of total Amount Month to Date compared to Total Amount for same Month last Year
  • Total Quantity Month To Date
  • Total Quantity for same Month Last Year
  • Total Quantity for Last Month
  • Variance of total Quantity Month To Date compared to Total Quantity for Last Month
  • Variance % of total Quantity Month To Date compared to Total Quantity for Last Month
  • Variance of total Quantity Month to Date compared to Total Quantity for same Month last Year
  • Variance % of total Quantity Month to Date compared to Total Quantity for same Month last Year

Period Measures

  • Total Amount Period To Date
  • Total Amount for same Period Last Year
  • Total Amount for Last Period
  • Variance of total Amount Period To Date compared to Total Amount for Last Period
  • Variance % of total Amount Period To Date compared to Total Amount for Last Period
  • Variance of total Amount Period to Date compared to Total Amount for same Period last Year
  • Variance % of total Amount Period to Date compared to Total Amount for same Period last Year
  • Total Quantity Period To Date
  • Total Quantity for same Period Last Year
  • Total Quantity for Last Period
  • Variance of total Quantity Period To Date compared to Total Quantity for Last Period
  • Variance % of total Quantity Period To Date compared to Total Quantity for Last Period
  • Variance % of total Quantity Period to Date compared to Total Quantity for same Period last Year
  • Variance of total Quantity Period to Date compared to Total Quantity for same Period last Year

Quarter Measures

  • Total Amount Quarter To Date
  • Total Amount for same Quarter Last Year
  • Total Amount for Last Quarter
  • Variance of total Amount Quarter To Date compared to Total Amount for Last Quarter
  • Variance % of total Amount Quarter To Date compared to Total Amount for Last Quarter
  • Variance of total Amount Quarter to Date compared to Total Amount for same Quarter last Year
  • Variance % of total Amount Quarter to Date compared to Total Amount for same Quarter last Year
  • Total Quantity Quarter To Date
  • Total Quantity for same Quarter Last Year
  • Total Quantity for Last Quarter
  • Variance of total Quantity Quarter To Date compared to Total Quantity for Last Quarter
  • Variance % of total Quantity Quarter To Date compared to Total Quantity for Last Quarter
  • Variance of total Quantity Quarter To Date compared to Total Quantity or same Quarter last Year
  • Variance % of total Quantity Quarter To Date compared to Total Quantity for same Quarter last Year

Year Measures

  • Total Amount Year To Date
  • Total Amount for Last Year
  • Variance of total Amount Year To Date compared to Total Amount for Last Year
  • Variance% of total Amount Year To Date compared to Total Amount for Last Year
  • Total Quantity Year To Date
  • Total Quantity for Last Year
  • Variance of total Quantity Year To Date compared to Total Quantity for Last Year
  • Variance% of total Quantity Year To Date compared to Total Quantity for Last Year

Mapping Dutch geographical data using Power BI

I have written before on the subject of using Power BIs mapping capabilities (see the post on ArcGIS) and using the maps with Dutch geographical data (see using Dutch postal codes in Power Map). However, I have never did a more thorough exploration of the mapping capabilities of Power BI using Dutch data. Until now! (Niels, thanks for requesting me to do this).

Please see the Power BI report below – the first tab shows the dataset I used. The other tabs show the way(s) to work with the various maps to plot Dutch data. Unfortunately the ArcGIS visual is not supported in the mode I use here – please download the original Power BI desktop file below. Enjoy!

Download Power BI Desktop file

Dutch elections analyzed in Power BI

Just in time for the elections in the Netherlands: I made an analysis using Power BI of the results of the elections since 1918. It is published (in Dutch) on the official Microsoft the Netherlands blog: https://blogs.microsoft.nl/technologieenmaatschappij/tweede-kamerverkiezingen-technologie-brengt-uitslagen-tot-leven/.

Enjoy!

Annual radio countdown Top 2000 in Power BI

Full screen

Most of this post will be in Dutch. Every year a list of 2000 songs is voted on by people from the Netherlands. This list is then broadcast by Radio 2 in the last days of the year. I decided to do a Power BI analysis on it and included all the lists from the start (1999). Also, I included an R-based forecast. If you want to get some insight into the musical taste in the Netherlands, go ahead and have fun!

De Top 2000. Fenomeen. Traditie. Zo’n ‘hoort-bij-de-tijd-van-het-jaar’ gevoel. Voor mij wel in ieder geval. Het is in ieder geval de beste afspiegeling van de muzieksmaak van Nederland die ik ken. Maar ja, wat heb je eraan als je geen vergelijking kunt maken met vorig jaar? 2000 nummers, dat is best veel om even te onthouden. En wie was ook alweer de grootste stijger vorig jaar? Wat is de oudste song in de lijst van jouw favoriete artiest? Welke song deed er het langst over om in de lijst te komen? Wat is er eigenlijk waar van de opmerking dat de lijst reageert op overlijden? Nu kun je het antwoord vinden op deze en vele andere vragen!

Ik heb namelijk alle Top 2000’s sinds het begin (1999) opgenomen in deze Power BI, als kerstcadeautje voor jou, lezer. Je kunt de analyse hieronder vinden. Ik heb drie views gemaakt: de eerste is gericht op artiesten zodat je meer te weten kunt komen over hoe jouw favoriete artiest het doet in de lijst. De tweede geeft inzicht in alles over een ‘versie’ van de Top 2000. Als bonus is er ook een forecast / voorspelling view (derde pagina). Hier kun je bekijken hoe op basis van de historie de positie van de artiesten / songs zich gaat ontwikkelen. Het mooiste is: alles is interactief.

Zo vinden we nu eindelijk het antwoord op de vraag of de lijst reageert op overlijden. Het antwoord is ja, kijk maar bij Michael Jackson (overleden 2009 en dat jaar zijn beste notering: #27) of Amy Winehouse (overleden 2011 en dat jaar haar beste notering: #72).

Doe er je voordeel mee. Ik vind het in ieder geval een mooie afspiegeling van de tijdsgeest. Ik wens jullie een fijne kerst!

Passing filters to Power BI reports using the URL / query string

It was only recently that I discovered this – you can pass filters to Power BI reports by deep linking to it and adding a filter in the URL (also called query string). I am not even sure this is a feature, since it only seems to work for ‘equals’ and does not work on Dashboards in Power BI.

First of all, we need to understand deep linking in Power BI. Most artifacts in Power BI (for example reports and dashboards) have a their own URL. This means we can open them directly when we know the URL. The URL will have the following format:

https://[tenant].powerbi.com/groups/[workspace]/[artifact type]/[artifact id]/[optional part to be opened]

Thus, the URL may look like this:

https://app.powerbi.com/groups/me/reports/dc121d4b-9aad-4494-b1de-8037f53d8355/ReportSection3

This would open page ReportSection3 in report with id dc121d4b-9aad-4494-b1de-8037f53d8355 in my personal workspace in the tenant app.

If you know anything about web development, you know that you can pass things through the URL to the application this is normally done by adding a question mark to the end of the URL and specifying whatever you want to pass. Multiple items can be added by separating them out by ampersands, like this:

https://myurl.com/?firstname=Jeroen&Lastname=ter%20Heerdt

(notice the %20, which is a URL encoded space).

Combining these two things, you can pass parameters to Power BI reports if you have the report URL (simply open the report to get that). Once you have it, add the following:

?filter=[tablename]/[columnname] eq ‘[filter value]’

So, if I wanted to filter the activity column in my workitem table so it only shows items where the activity is blogging, I would add the following:

?filter=workitem/activity eq ‘blogging’

(eq is short for equals here).

This needs, however, to be encoded for the URL. You can easily find tools online to do that for you, or if you know a little bit about what you are doing, you can do it by yourself. The addition above becomes:

?filter=workitem%252Factivity%20eq%20%27blogging%27

(/ becomes %252F, space becomes %20 and ‘ becomes %27)

This would open page ReportSection3 in report with id dc121d4b-9aad-4494-b1de-8037f53d8355 in my personal workspace in the tenant app with a filter set on the workitem table’s activity column to be equal to blogging:

https://app.powerbi.com/groups/me/reports/dc121d4b-9aad-4494-b1de-8037f53d8355/ReportSection3?filter=workitem%252Factivity%20eq%20%27blogging%27

By the way, you would probably only want to use this is very specific scenario’s. It is way better to look at Power BI Embedded to integrate Power BI in your applications. Note that Power BI Embedded is targeted at organizations providing software to others (hosted or not). It is not for internal applications.

Power BI Custom Visual Development Tip: VisualPlugin.ts: Property ‘Visual’ does not exist error

So here you are, creating your very own Power BI custom visual. You have read the documentation and ran the tutorial (https://github.com/Microsoft/PowerBI-visuals/blob/master/Readme.md and https://github.com/Microsoft/PowerBI-visuals-sampleBarChart). You feel proud because you are done creating your awesome looking 3d-piechart-barchart-mashup visual. Then it happens. You run: pbiviz start to view your visual and….BAM:

Ouch. Now, before you starting banging your head against the wall until it hurts, here is the solution:

Most probably you have (as good practice dictates) changed the class name of your visual from the default ‘Visual’ to something more interesting, such as MyAwesome3DpieChartBarChartMashupTheDutchDataDudeIsSoGoingToHateThisVisual.

Well, you forgot to change the visualClassName as specified in pbiviz.json so the code can actually find the entry point for your awesome visual. So, quick fix: open pbiviz.json and change the visualClassName property into your class name (which is hopefully not alike the one above). Save the file, re-run pbiviz start and done!

(I know this is a very newbie / getting started type of error, but it took me more than 5 minutes searching for it when I first encountered it. I figured it is worthwhile saving everyone’s time and log it for my own future reference ;))

First look: Esri ArcGIS Maps in Power BI

Esri is a leader in the GIS industry and ArcGIS is a very popular product to build great maps. Now, you can use ArcGIS maps in Power BI (in preview). See the official information here: https://powerbi.microsoft.com/en-us/blog/announcing-arcgis-maps-for-power-bi-by-esri-preview/. This is really cool, I know a lot of you have been asking for this for a long time!

You will find the option to enable this preview in PowerBI.com, not in the Power BI Desktop. Log in to PowerBI and open the settings. You can find the ArcGIS preview there and enable it by simply selecting the checkbox:

With that enabled, create a report with some geographical information (or edit an existing one). I used the Google Analytics data that keeps track of my blog. Google Analytics data can be loaded into Power BI simply by using the content pack. In edit mode in the report you will find the ArcGIS component in the Visualizations list:

Click it and create your map as you would with the normal map. I noticed it needs some time to build the map (probably due to the preview) but once it is done it is fully interactive with the other items on your report as you would expect:

You can change a lot of the ArcGIS options, such as switching out maps, changing symbol styles, adding reference layers, etc.

I love this – the awesome power of ArcGIS and Power BI combined! I cannot wait to see what you will create with this.

Power BI learning resources – follow up 3

Another great resource for learning about Power BI is the course on EDX: Analyzing and Visualizing Data with Power BI. Granted, has been around for a while, but I forgot blogging about it; maybe it is a bit easier to find now.

Enjoy the new skills you will learn with this!

 

Power BI Refresh scenarios against data storage solutions explained

A recurring theme with customers and partners is Power BI data refresh. More specifically, there is some confusion on what refresh scenario requires a Pro version and what can be done with the Free version of Power BI. I made the diagram below to help explain this. It shows the refresh scenarios against data storage solutions, such as SQL Azure, SQL in a virtual machine in Azure or SQL server on premises. I used these as examples, there are other options as well. I think the overall time carries over to other data storage solutions. The diagram shows the refresh that can be done using a Power BI Free account as orange and the refresh scenarios that need Power BI Pro as green lines. As shown in the diagram, if  you want to refresh against on-premises sources or a database running in a VM in Azure you will need a gateway and Power BI Pro. This applies not only to the creator of the report and schedule but also to every consumer. If you use PAAS solutions for data storage in Azure such as SQL Azure, it becomes a bit more difficult and it is really dependent on the type of refresh required. If you need a refresh cycle higher than once a day (either max 8 times per 24 hours or live) you will need Power BI Pro. If you just want to refresh against such as SQL Azure and once a day is enough you can do that using Power BI Free. Again, the license requirement carries over from author to viewer; if the author of the report requires Pro, then the viewers also need Pro.

Power BI Refresh scenarios against data storage solutions

Hope this helps. If you have any questions or feedback, please comment below!

Power BI and Cortana integration explored

With the big news of the Power BI and Cortana integration I could not wait until next week to publish this short video of me demo-ing this cool technology! In the video I ask Cortana a couple of questions on stats from my a part of my blog that I record using Google Analytics. How cool is that? This shows the unique ability of Microsoft to integrate a BI technology such as Power BI with Windows to make it very easy for users to get the information they need when they need it where they need it. Do you speak BI? Great stuff don’t you think?

%d bloggers like this: