Sort entire Pivot table in Excel 2013 by column - sorting

I have a Pivot Table with many columns.
I want the Pivot the ability to sort one of the columns in a way that the whole column is sorted and not the relative position in the hierarchy.
Example:
NAME PRODUCT SUM
Joe A 400
Joe B 200
Joe B 300
Alice A 500
Alice A 200
Alice C 300
If I use the regular sort on the Sum column, I will get the data sorted partially.
Alice A 500
Alice A 300
Alice C 200
Joe A 400
Joe B 300
Joe B 200
As you can see, the Sum column is sorted only relevant to the Name column.
I want the whole column to be sorted.
Expected result should look something like this:
Alice A 500
Joe A 400
Alice C 300
Joe B 300
Alice A 200
Joe B 200

If you have more than one field in the row area of the pivot table, you cannot create a sort purely by value. The hierarchy cannot be ignored. That's how a pivot table works. Don't shoot the messenger.

So, essentially, you want to sort the SUM columns first and then the NAME column and last the PRODUCT column.
Have a look in the MSDN Sort data in a PivotTable, I think that should do the trick

Add a dummy column in the data set and create an index (1 through the number of rows). If you pull that into the left-most column in your pivot, you'll be able to sort by the field you want. You can hide that column for visual purposes.

Related

Want to sort the data in column after 3rd position

I have a table named City and I want the output in a way like
first 2 rows should have values as "Chennai" then after that from the 3rd position it should sort remaining rows in ascending order starting from a-z.
Please help me with this.
Assuming you have two entries in City for Chennai you could do:
ORDER BY
CASE WHEN city = 'Chennai' THEN 0 ELSE 1 END,
city

HQL where clause query

I have data, and I am trying to find out if data from one column affects data in another column. I can't put my real data up but an example is:
A 12345
A 23456
A 34567
A 45678
A 56789
B 12345
B 23456
B 34567
B 45678
B 56789
What I am trying to do is find where the data in column B (numbers) appears more than once in Column A (A or B).
I have roughly:
select *
from database
where number < 56790
and > 12344
and COLUMN A ('A;, 'B');
I have tried many variations of the Where clause but cant seem to get it sorted. Any ideas?
I am new to coding so sorry if this has been asked before but I couldn't find an answer.
Thanks in advance
I have the select and from sections ok in my query, its just this one bit I cant get.

Sum and relates tables DAX

I do have a table(1) containing the cost and the Project number, line number and item number and would like to get the cost summarized in another table(2) in a new column where im having the project number and project line also. The second table does not have the item number and does also contain budget figures on the more aggregate level. The two tables are linked on Keyz.
Table1
Item Cost PjNumb PjLine Keyz
------------------------------------------------------------
Q000001403 24,35 QP00032 11300102 QP0003211300102
Q000001405 24,35 QP00002 11100102 QP0000211100102
Q000001404 24,35 QP00003 11200202 QP0000311200202
Table2
PjNumb PjLine Budget keyz
------------------------------------------
HG00057 1910 190000 HG000571910
HG00057 111001 190000 HG00057111001
HG00057 111002 0 HG00057111002
Ive done the following formula in table2
=CALCULATE(SUM(Table1[Cost]);ALL(Table1[keyz]))
I'm not getting any value out in the new column in table2.
Hope some one are able to help me. The Pjnumb and PjLine in table1 is retreived from a third table, not shown here.
Kr
Jan

How to filter rows in a table based on values in another table in power query

I have two tables in power query.
Price table
Date Company Price
01/01/2000 A 10
01/02/2000 A 12
01/03/2000 A 15
01/01/2000 B 15
01/02/2000 B 85
01/03/2000 B 98
Size table
Date Company Size
01/06/2000 A 10
01/06/2001 A 12
01/06/2002 A 15
01/06/2000 B 15
01/06/2001 B 85
01/06/2002 B 98
In Price table, I want only to have companies which are in size table. In other words, If company C is not in the size table, I do not need that company data points in the price table. Here no need to consider the date.
In Power Query you can use the Merge Queries function to achieve that. (In the Home --> Combine section of the ribbon.
Select the Join Kind to determine which rows to keep.
In your example, create a query from the 2nd table and apply the following steps:
Remove the date and the size column
Remove duplicates
Afterwards you can join the first table with the newly created query and do a inner join. (Only keep matching entries)

RSUM - Issue with sorting of columns

In my report, I've the data in the following way
The Rank is on the Revenue grouped by Category - RANK(Revenue by Category Name)
In the Results, the report is grouped by Category Name(By placing the Category Name in the sections)
The Revenue is sorted in descending order, so that when the RSUM is calculated, the first result should give Top Revenue, the third result should give the sum of top three revenues.
RSUM - RSUM(Revenue by Category Name)
when the Revenue is sorted(in the criteria),so that the results are expected as explained above, I'm getting the Rank to be 1 for most of the records and a few records with 2 and 3 rank and so the RSUM is also resulting in the same way.
If I don't sort with respect to Revenue , then the Rank and RSUM are behaving as expected but the records are being sorted by ID by default and this does not meet the purpose of RSUM top get the sum of Top 'n' Revenue.
You probably need to order by category first (either ascending or descending – probably doesn't really matter), then by Revenue (descending). Otherwise each of your categories are distributed throughout your dataset.

Resources