Pivots Archive | THE SELF-SERVICE-BI BLOG Wir lieben Microsoft Power BI Fri, 22 Mar 2024 16:26:04 +0000 de hourly 1 https://wordpress.org/?v=6.8 https://ssbi-blog.de/wp-content/uploads/2019/10/Favicon-150x150.png Pivots Archive | THE SELF-SERVICE-BI BLOG 32 32 How to build asymmetric pivots on Power Pivot data models using Named Sets https://ssbi-blog.de/blog/technical-topics-english/how-to-build-asymmetric-pivots-on-power-pivot-data-models-using-named-sets/ Sun, 21 Sep 2014 18:00:43 +0000 http://ssbi-company.de/?p=127 There are many financial reports out there, which have an asymmetric design, to give you all the numbers you need, for a certain place in time. Take a look at the following example to see, what I am talking about. This report gives an overview of Total Due by Territory, for March 2003. The columns in red square represent the single […]

Der Beitrag How to build asymmetric pivots on Power Pivot data models using Named Sets erschien zuerst auf THE SELF-SERVICE-BI BLOG.

]]>
There are many financial reports out there, which have an asymmetric design, to give you all the numbers you need, for a certain place in time. Take a look at the following example to see, what I am talking about. This report gives an overview of Total Due by Territory, for March 2003. The columns in red square represent the single months for year 2003, with its realized Total Due, until March. In green square you see the year-to-date value for 2003, which is the sum of all three single months. In orange you see a year-to-date value again, but this time it’s for the realized Total Due for the same period in the previous year. This is an asymmetric report design and you cannot do this with a „normal“ pivot table. But I have good news for you: You can build asymmetric pivots on Power Pivot data models and I will show you how, in this post.

 

Asymmetric Reporting of Total Due
Asymmetric pivot table design of Total Due

 

Why ’normal‘ pivots can’t be asymmetric

When we are talking about asymmetric pivot table design, why is this so special? Can’t normal pivots do that? The answer is: No, they can’t. Take a look at the following screenshot to understand why they can’t.

Why normal pivots cannot be asymmetric
Why normal pivots cannot be asymmetric

For creating the pivot table above, I did 3 main steps:

  1. I put MonthInCalendar on columns
  2. I put the three measures for Total Due on values and
  3. I filtered MonthInCalendar, so that only Jan 2003 till March 2003 is still active for this pivot table

What does the pivot table do? It creates each combination of the three measures and the three Months from MonthInCalendar and puts it on columns. The result is a report with nine columns, but we only want those in colored squares, which represent the columns from the first screenshot. Or in other words: We want to define, which combination of MonthInCalendar and the choosen measures shall be created.

This is something you can’t do with normal pivots, but you can do this with pivots, that are built on Power Pivot data models. Let’s see how it works.

 

How you make your pivot asymmetric, working on a Power Pivot data model

There is a way to create asymmetric design, when your pivot is based on a Power Pivot data model (or any other OLAP data source, that can be queried by Multidimensional eXpressions (MDX)). You can build Named Sets to reach this target. Named Sets allow you to define the combination of values and dimension to be shown in the pivot table.

 

How to create Named Sets via wizard

Excel has a nice wizard, which let’s you create your Named Sets quite easy. The next figure shows you the 4 steps to reach the wizard:

  1. step: Click in the pivot table
  2. step: Click on the context sensitive menu bar PivotTable Tools
  3. step: Click on Fields, Items & Sets
  4. step: Click on Create Set Based on Column Items. It is also possible to create Named Sets based on rows, but this isn’t what we’re going to do here.
How to reach the Wizard for creating Named Sets
How to reach the Wizard for creating Named Sets

 

When you reached the wizard, you can create your first Named Set, which means you can create your first defined combination of column headers and values you want. To create your first Named Set follow these steps:

 

  1. Step: Give your set a name. If you are preparing a monthly report, I strongly suggest to give it a name like 200303, which stands for March 2003. In a later post I will show you how to control these sets via slicer and therefore this systematic is necessarry.
  2. Sets can be organized in folders. It’s not mendatory to do so, but I suggest, to organize your Sets in folders like MonthlyReport_TotalDue.
  3. Step: Uncheck the checkbox Replace the fields currently in the column are with the new set. If you don’t uncheck this box, Excel will throw out the current fields in the pivot and replace it by the newly created set. If you uncheck it here, the set will be created, but not automatically put into the pivot table. You will see later in this post, why this would leed to en error, if you wouldn’t uncheck this checkbox.
  4. & 5. Step: On the left side of the following figure you see the wizard, when it opens. You see all combinations of MonthInCalendar and Values, that exist in the current pivot table. First delete all the rows you don’t need (we only need 5 columns in the pivot table, so we only need 5 rows in this wizard) and then use the dropdowns, to select which MonthInCalendar and Values you need.
Create Named Sets via Wizard
Create Named Sets via Wizard

 

Finding the created Named Set(s) in the pivot table field list

When you are finished with the definition of the Named Set press OK. To find the Named Set in the pivot field list click into the pivot table (1), click on PivotTable Tools (2), click on tab Analyze (3) and Field List (4). Then you will find the newly created Named Set in the Field List, in folder MonthlyReports_TotalDue.

Find the Named Set in the pivot field list
Find the Named Set in the pivot field list
Now, that we have found our Named Sets, how can we use it in the pivot table?

How to use Named Sets in pivot tables

Knowing, where the Named Sets hide, is not enough. How can we use them in our pivot table. Left of the Named Set is a checkbox, which looks quite promissing. When you try to check that checkbox you get the following error message.
Using Named Sets in pivots_error message
Using Named Sets in pivots – error message
The error message says, that a Named Set can not be added to the pivot table, when the fields, which the Named Set bases on, are still in the pivot table. Read that sentence carefully. It is not only about the Values, but also about the Slicers and the columns. Before we can add the Named Set to the pivot table, we have to remove all measures from the Values and remove the slicer and columns aswell. When that is done, you can select the Named Set by clicking the checkbox. The result will look like in the following figure.
Selecting Named Sets in the PivotTable fields list
Selecting Named Sets in the PivotTable fields list
The pivot tables now has the shape we were looking for. The special thing with the Named Sets is, that you don’t see any of the fields in the Values field. You only see the Named Set on columns. This is because the Named Set defines the columns AND the values to choose.
You can define as many Named Sets as you like in the way you have seen in this post. Because there is no dropdown for existing Set folders, take care you write the folder names correct. Until now, we have the Named Sets with the structure we want. But when the month changes, you have to select the next Named Set for April 2003 in the field list.
How to choose Named Stes manually by PivotTable fields list
How to choose Named Sets manually by PivotTable fields list

 

This is not a big deal, but not that easy for someone who does not even know about Named Sets and their behavior.
In my next post How to control Named Sets via Slicer using MDX, I will show you, how you can control the selection of these Named Sets by slicer, what makes the user experience much nicer 🙂

See you next time and keep in mind: Sharing is caring. If you liked this articel, feel free to share it.

Greets from Hamburg,

Lars

Der Beitrag How to build asymmetric pivots on Power Pivot data models using Named Sets erschien zuerst auf THE SELF-SERVICE-BI BLOG.

]]>