Group data in pivot tables by advanced rules - excel

I was wondering is there any way how to create pivot table in Excel with bit more advanced group by rules?
I am trying to create pivot table that will represent number of records for specified data ranges.
less than 3 days, 3 - 7 days, more than 7 days
I am looking for something simple. I would prefer to do it using Pivot table. Data over which I am trying to create this pivot table are generated on daily basis and input table already contains about 14 different columns. Therefore adding any additional columns is not the way to go
These are imput data
This is, what I am able to achieve
And this is, what I am trying to achieve
Is there any way how to achieve something like this using pivot table?
I am able to create something like this using macro, but it is kinda overkill. I assume there is something like this already implemented in Excel

Add a column in your raw data (with a suitable formula - Band1, Band2, Band3 etc) and use that in COLUMNS for the PivotTable.
Alternatively
Add three Calculated fields
=Aging<3
=AND(Aging>=3,Aging<=7)
=Aging>7
and add the counts for those:

Related

Excel query join tables

I have 4 tables reporting monthly sales of a product line; each table displays sales from a sdepcific channel (B2B, Ecommerce, Monobrand, Customized) and I'd like to stack these 4 tables one after the other.
Each table has the same exact columns, I can't do copy and paste because I need to update the 4 tables monthly.
I've tried to create a unique database and gather the information from the system throug a sequence of IF, IFS and SUMIFS but even though I get to the result, this takes forever in calculation
Is there a way to do it? I don't know, maybe with Powerquery or creating a Power Pivot?
Thank you
Load the tables into Power Query and append them in the Combine section of the Home tab.

Excel Pivot Table - Uneven group interval

I have around about 12,000 individual accounts with balances ranging from .01 to over 5mm. I want to group them in a column header so that I know the number of accounts that fall into each range as well as the summed up value of those accounts. I know how to create my pivot table to do this except for the grouping. I can only get one group to work (0-100,000 and >100,000). What I need is:
0-100,000; 100,000-1,000,000; 1,000,000-5,000,000; 5,000,000+
Can this be done? Manually grouping them isn't very viable given that I have 12,000 different account balances....and I wouldn't really want to do that manually anyway.
Can you add a calculated column to the source of the data with a formula to return the categories you want? A nested "If" statement should handle it with ease. Something along the line of:
=IF(AND(BALANCE>0,BALANCE<100000),"0-100,0000",IF(AND(BALANCE>=100000,BALANCE<1000000),"100,000-1,000,000"))
Just add in the rest of the IF(AND(X,Y),"Display text") to generate your categories.
You could skip the Pivot table entirely and use COUNTIFS
=COUNTIFS(A$1:A$10,">"&0,A$1:A$8,"<="&100000)
=COUNTIFS(A$1:A$10,">"&100000,A$1:A$10,"<="&500000)
And so on
For the last category you can use a COUNTIF
=COUNTIF(A$1:A$10,">"&5000000)
(My formulas assume the data is in Range A1:A10)

How to add multiple measures into a pivot table?

I'm quite new to using pivot tables and data models, so I don't even know if what I want to do is possible. I have a pivot table (PivotTable1) and its source (Table 25) and I would like to add a hundred or so measures which are listed in the TableCombinations.
For example, I entered the two first measure in orange, but they are not linked to TableCombination and entering them all one by one would be quite long. Each measure is for a distinct Sum wfn column that sums all other rows multiplied by a coefficient. The TableCombinations table simply states the coefficient to be used for each column. For the first three rows, these are my measure formulas :
sum wf1=1.4*Table25[Sum of wD]+0*Table25[Sum of wL]+0*Table25[Sum of wS]+0*Table25[Sum of wW]+0*Table25[Sum of wWSOUL]
sum wf2=1.25*Table25[Sum of wD]+1.5*Table25[Sum of wL]+1*Table25[Sum of wS]+0*Table25[Sum of wW]+0*Table25[Sum of wWSOUL]
sum wf3=1.25*Table25[Sum of wD]+1.5*Table25[Sum of wL]+0*Table25[Sum of wS]+0.4*Table25[Sum of wW]+0*Table25[Sum of wWSOUL]
...
Two questions :
Is there a way to link the tables so that any change made to TableCombination would then be updated in the pivot table measures?
Is there a way to generate all the of the measures without typing them in one by one.
You should be able to use just one DAX measure to do this, using the CROSSJOIN function.
Don't set up a relationship between the Tables, and drag # to the Columns area of the PivotTable. Then create this Measure:
=SUMx(CROSSJOIN(Table1,Table2),Table1[wD]*Table2[wD]+Table1[wL]*Table2[wL]+Table1[wS]*Table2[wS]+Table1[wW]*Table2[wW]+Table1[wWSOUL]*Table2[wWSOUL])
That should give you the exact answer you need.
Here's how it looks using some sample data:
...and here's the sample data I'm using:
You could certainly use VBA to add measures, and to update them when the Table changes. I might have a crack at writing up an answer along that approach shortly. But here's another way to achieve what you want.
I've previously written some code to slave a Table to a PivotTable, so that any change in the PivotTable's dimensions or placement will be reflected in the shadowing Table's dimensions and placement. This effectively gives us a way to add a calculated field to a PivotTable that can refer to something outside of that PivotTable. If the PivotTable grows, the Calculated Table will grow. If the PivotTable shrinks, the Calculated Table will shrink, and any redundant formulas in it will be deleted.
You can easily use this approach to perform your calculations in a 2nd table alongside your PivotTable, and each column x in that 2nd table could easily reference row x in your 'parameters' table.
See Select Newest Record and Create New Table of Unique Values in Excel

Import 2 or more columns from Excel into 1 column Access

I have an Excel report that is the output of an opinion tool. In this Excel I have all the responses that the people submit for my quizz, in the questions that are multiple choise answer the tool output those questions like one question per option and only the selected option is the column with data in the Excel. For example, if my quizz is like this:
Q1 Your name:
R1 =
Q2 Options
opt 1
opt 2
opt 3
The Excel report will appear like this
Excel Report
So I want that when I import the Excel to Access it can automatically merge those columns to have only to headers in the Access table: "Q1 Your name:" & "Q2 Options"
Also, for context of the job, I will make some other editions to that imported table and then copy to another Access table (table 2) so even if there is a way to merge those Access columns before copy to the another one I will accept it like, I don't know, insert from this column and if empty insert from that column, I'm not good at doing queries sorry. Only the table 2 will have information, the first table would be like a temporary one so I will daily delete information from that one and preserve the important data en the table 2
Thanks for the support
Simplest way I can see to achieve your goal is to concatenate the three columns; since by the sound of it you will only ever have a value in one column per question per record. You could do this in Excel prior to the import, you could use a calculated field on the table or you could build a query that concatenates all your questions. My suggestion would be Excel since using the =CONCATENATE() function is probably going to be easiest option for you.
If you do import your raw data into Access you will need to assign unique column names, ie Q2_Op1, Q2_Op2, Q2_Op3.
The query syntax to concatenate these fields one would be something like:
SELECT Q1_Name, [Q2_Op1] & [Q2_Op2] & [Q3_Op3] AS Q2_Options
FROM Table1;
Where Q1_Name, Q2_Op1, Q2_Op2, Q3_Op3 are the column names on the imported data table.

SSAS Calculated member that knows if the user is using the report filter

I am trying to write a calculated member which acts differently depending on whether the user is filtering by that member or has it dragged down as rows or columns on their pivot table (using Excel).
The rules are:
1. If the user is using the date dimensin as a Report Filter in Excel, then the calculated member should get the maximum date out of all dates that they are filtered by.
2. If they have the date dimension as rows on the pivot table, then I need to apply ClosingPeriod and some other logic.
Please try this. The idea came from here.
Basically the dynamic named set represents what's in the report filters. And the EXISTING keyword trims the list of days down to the filter context of the current cell letting you detect say if one month is on rows. Compare counts and you can detect what the user did.
CREATE HIDDEN DYNAMIC SET CURRENTCUBE.SelectedDays as
[Date].[Date].[Date].Members;
CREATE MEMBER CURRENTCUBE.[Measures].[My Calc] as
CASE
WHEN SelectedDays.Count > {existing [Date].[Date].[Date].Members}.Count
THEN Tail({existing [Date].[Date].[Date].Members},1).Item(0).Item(0).Name
WHEN SelectedDays.Count < [Date].[Date].[Date].Members.Count
THEN Tail(SelectedDays,1).Item(0).Item(0).Name
END
Performance is going to not be good. And I suspect users will be confused with the results of your calc. If you want to describe the business scenario more I can maybe recommend a better approach.

Resources