Unable to Collapse Pivot Table Hierarchy Connected to SSAS Tabular Model - excel

I work with Excel PivotTable connected to an SSAS Tabular Model.
I am using two dimension tables, Calendar and Link Number, attached to one Fact table, Sales, that has a simple, distinct count of sales orders as a measure.
In Calendar table, I have built a simple year/quarter/month hierarchy.
In Excel, I put the Calendar hierarchy on Rows, then Link Number column under it, with Sales Order Count in Values area.
I want to be able to collapse everything, including the link number field, up to the year.
Here is what I have at the moment:
Pivot table completely collapsed
Rows and Values layout
When I put each calendar component on rows, then put Link Number under it, the table collapses as expected:
The result I am looking for
Rows and Values layout using calendar components
I want to see the Results I am looking for image using the Rows and Values layout image.
Is this possible?

Related

Create a calculated pivot table column in excel based off other columns in the pivot table?

So I have a bunch of rows in a query table that shows orders from a certain timeframe and whether that order had a "defect" or not. I have started a pivot table on that table to summarize the # of orders and # of those orders that were defective by day (trying to start a p-chart).
Is there any way to create a 4th column in the pivot table that calculates the percent defective (Orders with Defects/Count of Orders) from the two existing columns?
Sure,
Based on this site, these are the steps:
To start, select any cell in the pivot table
Next, on the Excel Ribbon, go to the PivotTable Analyze tab
In the Calculations group, click Fields, Items, & Sets
Then, in the drop-down menu, click the Calculated Field command
Once there give a name to your Calculated Field and set your formula to Orders with defect / orders (tip: select the fields from the list to make sure you get the names right).
One last note: I believe calculated fields perform additions by default.. I noticed your 2nd column is a "count", I believe the calculated field will sum that column (before dividing) instead of counting it.

Combining Column Values in an Excel Pivot Table

In order to simplify a stacked bar chart, I am looking to sum up the counts of multiple columns I have in my pivot table. For example, in this sample table, I would like to combine Fruits and Vegetables into one column, so that each bar will comprised of three colors: one for Meats, one for Grains, and one for Fruits+Vegetables.
Pivot Table and Stacked Chart
For reference, this is the data source:
Data Source table
I tried adding a Calculated Field, but I'm not sure if I can use specific values from a column in the Formulas field. Is there a way to create something like this from a pivot table, or should I be taking a different approach to this all together?
I'm using Excel 2016, -- pretty sure it's the same with older versions, but the premise is the same.
In your pivot table, Select the Pivot Table Tools> Analyze tab, then "Fields, Items",then pull down to"Calculated fields". Enter a name for the generated field, and the formula you want to use:
In my example, I added the fields Fruit and Vegi's from my available pivot table fields (which is based on my data table).
Then select the calculated field as you would any other..
and create the chart as usual.
Hope this helps.

Ignore tier 1 rows in Excel pivot tables

I have a pivot table in Excel, and I'm trying to do some calculations on the results. This is all fine and good, but I'm running into a problem due to the grouping of a pivot table.
I have a dataset indicating transaction history for a particular client/patient at a vet clinic. These are reflected by clientID and patient name in my pivot table. I've used a pivot table to group by client then patient to see when the first purchase was made and how many total purchases there have been. I want to then do a calculation on that for each patient.
My problem is here. Excel has all the data for each client grouped in what I'll call "tier 1 results". The only data I want to do the calculation on are the "tier 2 results". These are row 7 and then rows 8-9 in the screenshot below.
In effect, I wan to include something in the equation in column F to ignore any bold text, but Excel doesn't appear to be able to do this. VBA is an obvious solution for me, but I'm creating steps for salespeople to use to analyze the data while they're out in the field. We need to keep things as simple as possible. Copying and pasting an in-cell equation is one thing, but using VBA is way over their heads.
Any thoughts on how to ignore the tier 1 results?
Your pivot table uses compact form layout, where all the groupings appear in one column. You can change that to tabular form to have each group level in its own column. The screenshot shows the difference:
Click a cell in the pivot table and then Pivot table Design ribbon > Report Layout dropdown > Tabular form. There are other settings to get rid of subtotal rows, etc.
Now you can build formulas that take into account only the level that you require. (It is also possible to repeat the pivot group labels for each group level where there are blanks.)

Excel Slicers for Measures

I have a cube with two measure(count of patients) and (distinct count of visits) , and various dimension(date,program,region,etc), when I browse the cube data from excel, I can choose all the dimensions in the slicer, but my question is is there anyway i can choose the measures in the slicer? From what I see, when I insert a slicer I only get to pick the dimesnions
Any help would be appreciated
I'm not sure of a way around using PowerPivot to do this, short of complicated VBA scripts.
To do it with PowerPivot:
Create a new table with two columns. Column 1 contains the name of your measures and column 2 contains an index for each. e.g.
and add this to the Data Model (but don't create any relationships to any other tables).
Create a new measure with a SWITCH function that has the same relationship between the measures and their values in the Index column, e.g.
[Chosen Measure]:=SWITCH(TRUE, MIN(MeasureTable[Index])=1, [DistinctPatients], MIN(MeasureTable[Index])=2,[DistinctDates])
Add the new measure to the values section of the pivot table and add the
Measure column from your new table to BOTH a slicer AND the column headings in the pivot table and remove the row and column totals.

Excel pivot table - average of calculated sums

I'm sure this is simple, but how do I get a pivot table to display an average for a calculated sum of fields? In the simplified example, I've filtered out fund x1, and the pivot table is showing the sums of the remaining funds per person. Now how do I get an average by person (so, manually calculated, 3300/3)?
I tried using a calculated field, but cannot figure out how it will work because the denominator will change based on how many people will have the funds I'm filtering on. If I use the averaging inside the calculated field it goes back to averaging the funds.
I tried putting the calculation outside the pivot table, and this works, but of course as I filter, my calculated field is no longer adjacent to the pivot table data, instead just floating off on the worksheet by itself.
TIA.
Per request here is the field list - if I try adding an "average of amount" to the value box it averages the fund amounts, instead of the fund amount per person. :
Here is a working solution:
Firstly you should install or enable Power Pivot. Quoting Microsoft:
Power Pivot is an Excel add-in you can use to perform powerful data
analysis and create sophisticated data models.
https://support.office.com/en-us/article/Power-Pivot-Powerful-data-analysis-and-data-modeling-in-Excel-a9c2c6e2-cc49-4976-a7d7-40896795d045?ui=en-US&rs=en-US&ad=US
In newer Excel versions Power Pivot is already installed and you can enable it by going to:
File > Options > Advanced > Data > Enable Data Analysis add-ins: Power Pivot, Power View, and Power Map
Alright, so you have Power Pivot now and you can see Power Pivot tab. Please follow the steps below:
Select your data and click add to “data model” icon on Power Pivot tab.
In Power Pivot window add column which will count distinct number of
persons in the data. =DISTINCTCOUNT([person]) name it for example
“DistPersNo”. This is crucial step – Power Pivot enables you to
count unique values in selected column.
Add another column with formula =[amount]/[DistPersNo] name it
“PersonAverages”.
In Power Pivot window click PivotTable and add new pivot table to
your worksheet.
In Pivot Table add 'persons' to rows and 'amount' to values. Now, if you add 'PersonAverages' to values (sum of it) and filter out fund 'x1' you will achieve desired result i.e. value of 1100.
Hope that helps.
I would add a helper column in column D to count unique customers.
Sort your data by person
In column D2 put =IF(A2=A1, 1, 0) and call the column UniqueCust
Copy formula down your dataset for all rows
Add the column to your pivot
Create a formula in your pivot table called Avg per Cust =Value/UniqueCust
This will flag each row in your data with a 1 if it is the first time a name appears in the column or zero otherwise. The pivot table calculation will sum up the total value and divide by the total unique customers.
I'm assuming that you want the value to come in any pivot table and not in a cell calculated outside the pivot table as a formula.
As a workaround you can use another pivot table, which takes the input as the original pivot table to find the average.
pivot tables
The second pivot table has data source as- E3:F5 or till whatever row you require.
You'll have to refresh all so that the second pivot table reflects any changes in the filter of first pivot table.
I've hidden (or you can filter it out) the grand total in the first pivot table so that the average gives the average of the sum of the amounts.
Since you didn't mention how you are using the data, I will give a couple of options that could work.
If you are the only user of the data or if someone else using the data is pivot table savvy you can use the following field list setups to switch data usage:
Sort by Fund (Note the Fund and Person in the Row labels section)
and Sort by Person (Note the reversed position of Fund and Person in the Row labels section)
To simplify the data, you can always minimize the main fields.
If you are distributing the pivot table to other people who aren't able or willing to modify the pivot table data, I would recommend setting up two separate pivot tables (using the same data source) with the same setups that I showed above.
Click the pivot table to bring up the field list.
In the Values section where it says "Sum of Amount" click the drop down.
Click "Value Field Settings" and choose average from the list in the pop-up.

Resources