Removing Excel Pivot-table columns but retaining grand total - excel

I'm using Excel pivot-tables to produce a report. The pivot-table connects to a SSAS cube. I have 2 measures- measure 1 is a 'real' measure, measure 2 is calculated based upon measure 1. Measure 1 must be shown broken out by dimB members across the columns. WIth Measure 2 I just want the totals column.
I've hidden the measure 2 columns as a workaround but this is less than ideal as when users expand or contract the dimension B members the pivot-table moves relative to the hidden columns and the report becomes a mess. It's also returning extra data which can't help performance.
Here is what I have:
Measure 1 Measure 2 Measure 1 Total Measure 2 Total
a b c a b c
DimA- member1 2 3 4 2 3 4 9 9
DimA- member2 1 4 5 1 2 5 10 8
This is what I want:
Measure 1 Measure 1 Total Measure 2 Total
a b c
DimA- member1 2 3 4 9 9
DimA- member2 1 4 5 10 8
Is there a way to achieve the second option? Either with perhaps some mdx on the calculated measure (scope/custom rollup etc) or with the pivottable itself?
Basically I want the total without the dimension B breakdown for measure 2.

I don't know that technique, and afraid, that it's impossible.
What if to NULLify all members in scope at least for the lowest levels?
Something like this:
SCOPE ([Measures].[Measure 2 Hide]);
THIS = IIF(Axis(1).Item(0).Item(0).Hierarchy.Level.Ordinal=1
,[Measures].[Measure 2],null);
END SCOPE;
Or <2 instead of =1. Measure 2 will be at least empty for users.
Here is my Excel example (measure is called Measure 2 Hide):
CREATE MEMBER CURRENTCUBE.[Measures].[Measure 2 Hide]
AS
[Measures].[Count]-1,
VISIBLE = 1;
I understand that it's not a solution, but maybe will help somehow.

Related

Compare multiple data from rows

I'm looking for a way to compare multiple rows with data to each other, trying to find the best possible match. Each number in every column must be an approximately match the other numbers in the same column.
Example:
Customer #1: 1 5 10 9 7 7 8 2 3
Customer #2: 10 5 9 3 5 7 4 3 2
Customer #3: 1 4 10 9 8 7 6 2 2
Customer #4: 9 5 6 7 2 1 10 5 6
In this example customer #1 and #3 is quite similar, and I need to find a way to highlight or sort the rows so I can easily find the best match.
I've tried using conditional formatting to highlight the numbers that are the similar, but that is quite confusing, because the amount of data is quite big.
Any ideas of how I could solve this?
Thanks!
The following formula entered in (say) L1 and pulled down gives the best match with the current row based on the sum of the absolute differences between corresponding cells:-
=MIN(IF(ROW($C$1:$K$4)<>ROW(),(MMULT(ABS($C1:$K1-$C$1:$K$4),TRANSPOSE(COLUMN($C$1:$K$4))^0))))
It is an array formula and must be entered with CtrlShiftEnter.
You can then sort on column L to bring the customers with lowest similarity scores to the top or use conditional formatting to highlight rows with a certain similarity value.
EDIT
If you wanted to penalise large differences in individual columns more heavily than small differences to try and avoid pairs of customers which are fairly similar except for having some columns very different, you could try something like the square of the differences:-
=MIN(IF(ROW($C$1:$K$4)<>ROW(),(MMULT(($C1:$K1-$C$1:$K$4)^2,TRANSPOSE(COLUMN($C$1:$K$4))^0))))
then the scores for your test data would come out as 7,127,7,127.
I'm assuming you want to compare customers 2-4 with customer 1 and that you are comparing only within each column. In this case, you could implement a 'scoring system' using multiple IFs. For example,:
A B C D E
1 Customer 1 1 1 2
2 Customer 2 1 2 2
3 Customer 3 0 1 0
you could use in E2
=if(B2=$B$1,1,0)+if(C2=$C$1,1,0)+if(D2=$D$1,1,0)
This will return a 'score' of 1 when you have a match and a 'score' of 0 when you don't. It then adds up the scores and your highest value will be your best match. Copying down would then give
A B C D E
1 Customer 1 1 1 2
2 Customer 2 1 2 2 2
3 Customer 3 0 1 0 1
so customer 2 is the best match.

Excel formula to apply penalty column to ranking

I have thought long and hard about this, but I can't find a solution to what I believe is quite a simple problem.
I have a table of results, where sometimes someone will be given a penalty of a varying amount. This is entered into the penalty column (Col C).
I need a formula which checks if there is an entry into the penalty column and applies it, not only to that row, but to the number of subsequent rows which are affected, depending on the severity of the penalty.
I have tried to see if this is possible by referencing the penalty against the 'ROW()' function but have not been able to achieve the desired effect.
Col D shows the desired output of the formula.
Col E is included for reference only, to show the desired effect on each row.
Col A Col B Col C Col D Col E
Pos Name Penalty New Pos Change
1 Jack 1 0
2 Matt 2 0
3 Daniel 2 5 +2
4 Gordon 3 -1
5 Phillip 4 -1
6 Günther 6 0
7 Johann 3 10 +3
8 Alain 7 -1
9 John 8 -1
10 Gianmaria 9 -1
The big issue is, if someone is handed a big penalty, for example '10' then it affects the following ten rows. I can't work out how to include this variable logic...
I would be interested to hear the approach of others...
You need to use the RANK() function:
Excel RANK Function Examples
In a new column, add the penalty value to the original position, plus a small coeffieient depending on the original position (0.01 per increment perhaps) to move the penalised player below the original person at that position, then in the next column you can RANK() the new column of values (F in my case).
New value is therefore =A2+(IF(C2>0,C2+(0.01*A2)))
Rank is then =RANK(F2,F2:F11,1)
You can combine all the functions into one, but it's clearer to do it in separate columns at first.

EXCEL - Comparing Two Columns - Removing Repeats

If two households share, they create a tie and this tie has a kinship rank that does not change, no matter how often two households share with each other.
KINSHIP RANK EXAMPLE
As you can see, it doesn't matter in which "direction" the tie happened whether it was household 5 who shared to household 3 or vice versa, the kinship rank is still 1
HH1 HH2 RANK
5 3 1
3 5 1
Therefore, I do not need every tie that occurs between two households, but only the first instance that a tie occurred between the two households.
So here is a sample list of many households who shared with each other, sometimes sharing resources with themselves, sharing only once, or sharing multiple times with the same household.
TWO HOUSEHOLD WITH REPEATED TIES
COL.A COL.B
ROW HH1 HH2
1 1 1
2 1 2
3 1 3
4 2 1
5 2 4
6 3 1
7 3 2
8 3 4
9 4 2
This is what I need it to look like:
TWO HOUSEHOLDS WITHOUT REPEATED TIES
COL.A COL.B
ROW HH1 HH2
1 1 1
2 1 2
3 1 3
4 2 4
5 3 2
6 3 4
What I have done
I wrote a simple command for placing the HH1 and HH2 information into the same cell:
=A1&"|"&B1
In the case of the second row, this looks like 1|2 inside cell C2
HH1 and HH2 are combined in column C so how will I be able to compare all of the households in column C to each other? Perhaps a highlighting rule if a repeat happens? Or in another column list if it is a delete or a keep?
Thank you for your assistance everyone.
I suggest a simple COUNTIFS to do the job like this:
=(COUNTIFS(A$1:A1,B2,B$1:B1,A2)+COUNTIFS(A$1:A1,A2,B$1:B1,B2))>0
starting in C2 and then copy down. It will show TRUE for each row which is within the range above it and false if not. Ich checks for both x/y and y/x (the order doesn't matter)
Now simply filter col C to only show rows with TRUE in it. Then simply select and delete it.
This also works with non numerical values like names.
If you still have any questions, just ask ;)
You also can wrap it up to get more informations like this:
=IF((COUNTIFS(A$1:A1,B2,B$1:B1,A2)+COUNTIFS(A$1:A1,A2,B$1:B1,B2)),"",COUNTIFS(A:A,B2,B:B,A2)+COUNTIFS(A:A,A2,B:B,B2))
For C2 and copy down. C1 gets:
=COUNTIFS(A:A,B2,B:B,A2)+COUNTIFS(A:A,A2,B:B,B2)
This will show you only at the first occurrence how many times it is within the whole range.
All done by phone, may contain errors
Use =((A1*B1)/(A1+B1))*((A1*B1)+(A1+B1)) to create unique identifiers. Then use Remove Duplicates in the Data Tools Pane of the Data Tab to remove all rows containing duplicates. Or, alternatively, use something like =IF(IFNA(MATCH(A2,A$1:A1,0),TRUE())=TRUE,"First Share","") dragged and dropped from row 2 to identify First Shares.

Average values in a column by Class

I need to create something that is used to track and report class ratings. The class evaluation form has eight questions and the ratings are from 1-4. We need to show the average rating for each question per class. It will be an ongoing list so needs to have functionality that allows users to continue to add new class ratings without re-formatting the spreadsheet.
Example, Class PD100 has a total of 5 for Q1. I need to show the average score of 1.6 for that question. Then the same for all the other questions grouped by Class.
Class # Q1 Q2 Q3 Q4
PD100 1 2 3 1
PD100 3 2 3 4
PD100 1 2 3 1
PD200 2 1 2 2
PD200 1 2 3 4
PD200 1 4 1 4
PD300 1 4 4 1
This is a bit unwieldy as the data is already laid out in a pivot, but the total average columns give you what you're looking for in creation of a pivot table.
if the data was laid out class question answer the pivot could be cleaner.
.

will ABS formula columns sort and match

I am retired so I have a lot of free time on my hands so I like playing the greyhounds. Using Excel I attempted to help myself save time by sorting out two columns at a time (Post - B-SPD) etc, because you have to sort some low and some high. The columns not marked Post are formula columns =abs(a3) etc. but when I try to sort the Post columns will sort, but the column I try to sort with it does not sort and match the post number it is assigned to.
Can this be done or does the =ABS formula prevent it. Plus even using =ABS some of the number are negative but the -minus sign does not appear. I have tried everything using numbers, using currency, using general, but nothing works. One person sent me to control panel to the Clock, Language, and Region settings. go additional setting and set your negative setting there. But that would not let the -minus sign show up on negative numbers either.
Is any of the above even possible?
POST B-SPD POST A-SPD POST 8TH POST L-SPD POST A-FIN
1 31.43 1 31.84 1 0 1 3 1 5.83
2 31.43 2 31.67 2 35.14 2 0 2 4.67
3 31.79 3 31.9 3 59.11 3 6 3 5.67
4 31.32 4 31.73 4 65.5 4 3 4 3.83
5 31.47 5 31.68 5 29.71 5 4 5 3.33
6 31.76 6 32.18 6 100 6 9 6 5.01
7 31.48 7 31.99 7 41.13 7 1 7 5.67
8 31.69 8 31.99 8 75.79 8 6 8 4.83
LOW LOW HIGH HIGH LOW
The requirement is not clear but use of ABS should not cause sorting issues. =ABS (for absolute) function is to strip out minus signs (so seems to be working properly).
OP may be advised to delete all but one of the POST columns, select headers and data (not including 'LOW' or 'HIGH') and Insert > Tables - Table, check My table has headers, OK, then use the filter buttons to choose whether to Sort Smallest to Largest or Sort Largest to Smallest for whichever attribute is to be ordered (the other columns will 'follow suit'). The filter button will show which button is determining the ordering and whether ascending or descending (eg table below is sorted descending on '8TH'):

Resources