A while ago I was working on a Power BI project which the customer wanted to define a new table directly in the model. The easiest way to achieve this in Power BI Desktop is to “Enter Data” which creates a new table by typing or pasting in new contents. I was thinking of that project the other day and thought, hey, how we can do the same in SSAS Tabular when there is no Power Query (M) language available in SSAS Tabular 2016. The good news is that Power Query will be available in the next version of SSAS Tabular in SQL Server vNext. But, until then a workaround would be entering data to a CSV file then load it to the model. Another way is to implement custom tables in DAX in SQL Server 2016 Tabular models using Table and Row Constructors. In this post I show you a way of creating custom table in SSAS Tabular using table constructors in DAX. You can do the same in Power BI as the same principle applies. Therefore, in case you’d prefer not to use “Enter Data” feature which effectively uses Power Query to create a new table in Power BI Desktop, then you can use DAX to do the same.
If don’t already have SQL Server 2016 it’s probably time to download and install it. I use AdventureWorksDW as sample database in this article.
You are involved with an SSAS Tabular project and the customer asked for a report in Power BI with dynamic Card so that the values shown in the Card visual should dynamically change based on selected measure from a slicer. You have several different measures in the model and the customer wants to show some of them dynamically in only one Card visual. Consider you have the following measures to be shown in the Card:
- Total Internet Sales
- Internet Sales in 2014
- Total Number of Internet Sales Transactions
You have to create a logic so that the users can selected any of the above measures to show in a single Card visual.
How it works
After you meet the requirements, you’re good to start implementing the above scenario in SQL Server Data Tool (SSDT). Creating a calculated table in SSAS Tabular 2016 is fairly easy. All we need to do is to create a custom table with two columns. One column stores friendly names for measures and the other one holds DAX expressions for the measures. As you might have noticed, I’m talking about creating a custom table in DAX and populating it with values. Continue reading to see how. What we are going to do is to create a calculated table using table constructors in DAX. Table and Row Constructors weren’t available in previous versions of DAX in SSAS Tabular. They are very similar to Lists or a list of Tuples just like what we have in MDX.
I’ll explain this later when we created our sample model in SSDT. Continue reading Creating Custom Table in SSAS Tabular using Table and Row Constructors in DAX
One of the coolest features in Power Pivot is the ability to define KPIs based on calculated measures. You can create KPIs in SSAS Tabular as well. Unfortunately, this feature is missing from Power BI. In this post I show you a very simple way to import KPIs and use them in Table, Matrix, Multi-row card and Card visualisations in Power BI.
I use the word “IMPORT” as this feature is NOT available in Power BI Desktop yet so we CANNOT create KPIs directly in Power BI Desktop, but, there is work around for it that I explain it in this post.
- Latest version of Power BI Desktop
- Microsoft Excel (2007 or later)
- Power Pivot add-on if using Excel 2007 to 2013 (Power Pivot is already available in Excel 2016)
- Power Query add-on if you need to transform your data (Power Query is available only in Excel 2010 Professional Plus and Excel 2013. It’s added to Excel 2016 as a built-in feature. Check this out to find out more about BI features in Excel 2016.). In this post I’m not loading data using Power Query, so you can ignore Power Query if you want to follow this article to make your first sample KPI work.
How It Works
The work around is really easy. You only need to
- open Excel
- load data into Power Pivot model from your source
- create desired calculated measures in Power Pivot
- create desired KPIs on top of your calculated measure(s)
- save the Model (Excel file)
- import the Model to Power BI Desktop
Let’s go through the whole process step-by-step to see how it works on real world.
Note: I use Excel 2016 and Adventure Works DW SQL Server sample database. If you’re using prior versions of Excel, you have to download and install Power Pivot for Excel. All steps below are pretty much the same.
- Open Excel 2016
- From Data tab click “Manage Data Model”
Note: In case you’re using prior versions of Excel you need to click “Manage” from Power Pivot tab. All other steps would be the same.
- Get external data from SQL Server
- Enter server name and database name then click Next
- Select “FactResellerSales”, “DimProduct”, “DimProductCategory” and “DimProductSubCategory” then click Finish
- After the data successfully imported click Close
Continue reading Use KPI in Table, Matrix and Card Visualisations in Power BI
One of the most powerful features in Power BI and Excel is supporting geospatial visualisations. In Excel we can use Map visualisation in Power View, or use Power Map directly. In Power BI, as you know, there are two built-in visualisations supporting geographic coordinate data, Map and Filled map. They work beautifully if you have enough data supported by Bing Maps. But, there are some issues with Map visualisations in both Power BI and Excel. In this post I address some of the issues I faced myself and I’ll provide the solutions for the issues. As “Filled Map” and “Map” visualisations in Power BI are very similar my focus in this post would be on “Map” visualisation. My intention is not explaining Power View and Power Map that much so my focus in this article would be on Power BI more than the other two.
To experiment everything I explain in this post you need to have:
- The new SQL Server sample, WideWorldImportersDW (WWI). You can download it here
- The latest version on Power BI Desktop (current version is 2.35.4399.381 64-bit (May 2016))
- Excel 2016 or Excel 2013
If you use Excel 2016, then you need to turn on Power View on.
Check this out if you want to learn more about BI features in Excel 2016.
Get Data in Power BI
- Open Power BI Desktop
- Get Data from SQL Server Database
- Select Fact.Sales and Dimension.City then load data
Map Issues In Power BI
Wrong Cities in Power BI
- Expand the “Dimension City” table
- Select “City” column then change its Data Category to City (Data Category is on “Modeling” tab from the ribbon)
- Put a Map visual into the page
- Put “City” on Location
- Put “Total Excluding Tax” on Size
As you see sales distributed across different countries, but, this is not quiet right.
- Put a slicer on the page then put “Country” on the slicer
- Click “United States” to filter the Map
Oops! This is not quiet right. What happened is that Bing Map Engine gets confused with the city names so that it shows a city with the same name outside of the US, just like New Plymouth which a city in New Zealand, but, the New Plymouth we have in our data source is the New Plymouth from Idaho in the US.
Continue reading How to Overcome Map Related Issues in Power BI, Power View and Power Map
Role-playing dimension is one those concepts that is discussed a lot from time to time. I also posted an article about implementing role-playing dimensions in Tabular models. In one my recent posts I used the same concept to implement role-playing dimensions in Power BI. So in this post I’m not going to explain role-playing dimensions in Power BI again.
In some cases you need to have especial calculated measures based on the roles you have in a fact table. One the most common role-playing dimensions is Date dimension. Consider you have to show Internet Sales Amount by Order Date, Due Date and Ship Date in a single chart in your report. In this case, having 3 different date tables won’t help us to achieve the goal. Again I refer to my previous post where I said I keep the original Date table in the model for a reason.
Defining a new Calculated Measure in Power BI Desktop
Basically, what I’m going to explain in this post is using inactive relationships between FactInternetSales table and the DimDate dimension by adding a new Calculated measure. In this case, we’ll be able to show Sales Amount by different roles, well, dates in this sample in a single chart.
Continue reading Side-by-side Role-Playing Dimensions In Power BI
It’s been awhile that lots of us were waiting for this feature. And some of us like me just tried to build it in our way. I spent some time to develop something similar using OData in combination with IIS and Basic Authentication features. Well, it was sort of successful and unsuccessful simultaneously! I mean, I was able to refresh SQL Server data remotely, but, when it came down to refreshing the dataset uploaded into the cloud Power BI it just failed. It was mainly because of the method that Power BI uses to refresh data.
By the way, I’m glad to see that we are finally able to refresh an on-premises SQL Server database from Power BI website. Refreshing data is very crucial for every report and dashboard which is working on top of frequently changing database. So we need to be able to schedule a data refresh on the cloud. Yesterday Microsoft announced a new gateway specially designed for supporting data refresh for on-premises data sources as below:
SQL Analysis Services Tabular model (uploaded data, not live connections)
File (CSV, XML, Text, Excel, Access)
Custom SQL/Native SQ
As you see SQL Server is not the only one.
Installing Power BI Personal Gateway
It’s easy to install the Gateway. Just make sure that meet the following requirements:
It’s been awhile that we are waiting for a sensible improvements in Microsoft self-service BI. The good news is that finally there will be some cool new features added to the next version of Excel which is Excel 2016. By some, I mean, well, there not a lot new BI features, but, some. Something is better than nothing, not too bad though!
Integrating BI features with Excel:
Power View and Power Map:
As you know, Power Pivot was integrated as a built-it feature to Excel 2013. Now I’m really happy that the same thing happened to Power View and Power Map. So you don’t need to install them separately. You can now turn these features on from:
File–> Options–> Advanced-> (scroll down the page) Data-> Enable Data Analysis Add-ins: Power Pivot, Power View, and Power Map
OR you can still turn them on from “COM Add-ins”:
Continue reading What is new for BI in Excel 2016
In this post I express an easy way to refresh a PowerPivot model dynamically based on SQL Server Stored Procedures. Let’s start with SQL Server Management Studio (SSMS) 2012 and use Adventure Works 2012 database. Run the following script to see the results in SSMS:
exec [dbo].[uspGetBillOfMaterials] 727, ‘2009-01-02’
First parameter: Start Product ID
Second Parameter: Check Date
Now we want to see the results for the following script:
exec [dbo].[uspGetBillOfMaterials] 762, ‘2009-01-02’
Now we want to do the same with PowerPivot.
Continue reading Dynamically Passing Parameters to a SQL Stored Procedure from PowerPivot Using VBA