Excel: Sort one column into many column - excel

I would like to do the following data sorting/reshaping in excel. Is there a way to do this?
From this
+--------+-------+
| Sample | Value |
+--------+-------+
| 1 | 30 |
| 1 | 10 |
| 2 | 6 |
| 2 | 5 |
| 3 | 62 |
| 3 | 20 |
+--------+-------+
To this
+---------+---------+---------+
| Sample1 | Sample2 | Sample3 |
+---------+---------+---------+
| 30 | 6 | 62 |
| 10 | 5 | 20 |
+---------+---------+---------+
edit: please excuse my ugly table.

If 30 is in B2, please try in C2:
=OFFSET($B2,2*(COLUMN()-3),0)
copied across and down to suit.

Related

Create descending list inlcuding duplicates based on filter criteria

Excel-File
| A | B | C | D | E | F |
---|--------------|-------------------|--------|-----------------|------------|------------|-
1 | Sales | Product | | Product | Sales | |
2 | 20 | Product_A | | Product_D | 100 | Product_D |
3 | 10 | Product_A | | Product_D | 90 | |
4 | 50 | Product_A | | Product_D | 50 | |
5 | 80 | Product_B | | Product_D | 50 | |
6 | 40 | Product_C | | | | |
7 | 30 | Product_C | | | | |
8 | 100 | Product_D | | | | |
9 | 90 | Product_D | | | | |
10 | 50 | Product_D | | | | |
11 | 50 | Product_D | | | | |
12 | | | | | | |
In Column B I have list of different products with their corresponding sales in Column A.
Products can appear mutliple times in the list.
Sales numbers can be equal for multiple products.
I want to use the value in Cell F2 as Filter-Criteria to create a descending list of the products in Column D and Column E sorted by the sales in Column A.
Therefore, I tried to add the FILTER function to the formula from this question:
=INDEX(SORT(FILTER(A2:B11,A2:A11=F2,""),2,-1),SEQUENCE(COUNT(A2:A11)),{2,1})
However, with this formula I get error #VALUE.
How do I need to modify the formula to make it work?
Simply add COUNTIF() inside the SEQUENCE():
=INDEX(SORT(FILTER(A2:B11,B2:B11=F2,""),2,-1),SEQUENCE(COUNTIF(B2:B11,F2)),{2,1})
Current view on OP side:
Due to unknown reason only Column D gets filled.

Auto Incrementing Number Values in Excel

I have to re-number over 30,000 rows in excel and am looking for a way to do this through an embedded excel function.
I have two columns, the original BuildingCount and the Test column. In the BuildingCount column, I have inconsistent count that needs to be consecutive 1,2,3 numbers in order to run a macros. However, the numbers are not always consecutive. I have been writing different variations of excel functions. The below is the output for =IF(A2>1),A2+1,1)
+----+---------------+------------+
| | A | B |
+----+---------------+------------+
| 1 | BuildingCount | TestColumn |
| 2 | 1 | #VALUE! |
| 3 | 2 | 1 |
| 4 | 3 | 3 |
| 5 | 5 | 4 |
| 6 | 6 | 6 |
| 7 | 9 | 7 |
| 8 | 1 | 10 |
| 9 | 2 | 1 |
| 10 | 3 | 3 |
| 11 | 4 | 4 |
| 12 | 5 | 5 |
+----+---------------+------------+
Ideally, the output would be the following:
+----+---------------+------------+
| | A | B |
+----+---------------+------------+
| 1 | BuildingCount | TestColumn |
| 2 | 1 | 1 |
| 3 | 2 | 2 |
| 4 | 3 | 3 |
| 5 | 5 | 4 |
| 6 | 6 | 5 |
| 7 | 7 | 6 |
| 8 | 1 | 1 |
| 9 | 2 | 2 |
| 10 | 3 | 3 |
| 11 | 4 | 4 |
| 12 | 5 | 5 |
+----+---------------+------------+
Any ideas would be very welcomed.
Formula in B2:
=IF(ROW()=2,1,IF(A2>A1,B1+1,1))
And dragged down

Show text as value Power Pivot using DAX formula

Is there a way by using a DAX measure to create the column which contain text values instead of the numeric sum/count that it will automatically give?
In the example below the first name will appear as a value (in the first table) instead of their name as in the second.
Data table:
+----+------------+------------+---------------+-------+-------+
| id | first_name | last_name | currency | Sales | Stock |
+----+------------+------------+---------------+-------+-------+
| 1 | Giovanna | Christon | Peso | 10 | 12 |
| 2 | Roderich | MacMorland | Peso | 8 | 10 |
| 3 | Bond | Arkcoll | Yuan Renminbi | 4 | 6 |
| 1 | Giovanna | Christon | Peso | 11 | 13 |
| 2 | Roderich | MacMorland | Peso | 9 | 11 |
| 3 | Bond | Arkcoll | Yuan Renminbi | 5 | 7 |
| 1 | Giovanna | Christon | Peso | 15 | 17 |
| 2 | Roderich | MacMorland | Peso | 10 | 12 |
| 3 | Bond | Arkcoll | Yuan Renminbi | 6 | 8 |
| 1 | Giovanna | Christon | Peso | 17 | 19 |
| 2 | Roderich | MacMorland | Peso | 11 | 13 |
| 3 | Bond | Arkcoll | Yuan Renminbi | 7 | 9 |
+----+------------+------------+---------------+-------+-------+
No DAX needed. You should put the first_name field on Rows and not on Values. Select Tabular View for the Report Layout. Like this:
After some search I found 4 ways.
measure 1 (will return blank if values differ):
=IF(COUNTROWS(VALUES(Table1[first_name])) > 1, BLANK(), VALUES(Table1[first_name]))
measure 2 (will return blank if values differ):
=CALCULATE(
VALUES(Table1[first_name]),
FILTER(Table1,
COUNTROWS(VALUES(Table1[first_name]))=1))
measure 3 (will show every single text value), thanks # Rory:
=CONCATENATEX(Table1,[first_name]," ")
For very large dataset this concatenate seems to work better:
=CALCULATE(CONCATENATEX(VALUES(Table1[first_name]),Table1[first_name]," "))
Results:

How to get and concatenate values from one column based on another column in Excel

Excel is beating me up for a day here.
I have this table:
+---+--------+--------+--------+--------+
| | A | B | C | D |
+---+--------+--------+--------+--------+
| 1 | AGE | EX# | DG1 | DG2 |
+---+--------+--------+--------+--------+
| 2 | 19 | C01 | ASC | |
+---+--------+--------+--------+--------+
| 3 | 45 | C02 | ATR | |
+---+--------+--------+--------+--------+
| 4 | 27 | C03 | LSI | |
+---+--------+--------+--------+--------+
| 5 | 15 | C04 | LSI | |
+---+--------+--------+--------+--------+
| 6 | 49 | C05 | ASC | AGC |
+---+--------+--------+--------+--------+
| 7 | 76 | C06 | AGC | |
+---+--------+--------+--------+--------+
| 8 | 33 | C07 | ASC | |
+---+--------+--------+--------+--------+
| 9 | 17 | C08 | LSI | |
+---+--------+--------+--------+--------+
Now, I need to create a new table based on that data, with one row and one column, which I'll fill column A and need a formula to fill column B:
+----+--------+---------------+
| | A | B |
+--=-+--------+---------------+
| | DG | AGE |
+--=-+--------+---------------+
| 10 | AGC | 49, 76 |
+----+--------+---------------+
| 11 | ASC | 19, 33, 49 |
+----+--------+---------------+
| 12 | ATR | 45 |
+----+--------+---------------+
| 13 | LSI | 15, 17, 27 |
+----+--------+---------------+
So I need a formula to check the first table's columns C and D for each DGs, and check the age of each one in column A, and then concatenate all values that match into one cell with a , as a separator.
Can anyone help me?
Thanks
On the great excel website from Chip Pierson, I found the custom function: StringConcat. Just copy-paste the code in a VBA module.
Something like the following formula (in cell B10 & fill down)should work for you. It's an array formula (commit with [ctrl-shift-enter]
=StringConcat(", ",IF(Sheet1!$B$2:$C$100=A10,Sheet1!$A$2:$A$100,""))
You'll have to adjust the ranges off course.

excel I need formula in column name "FEBRUARY"

I have a set of data as below.
SHEET 1
+------+-------+
| JANUARY |
+------+-------+
+----+----------+------+-------+
| ID | NAME |COUNT | PRICE |
+----+----------+------+-------+
| 1 | ALFRED | 11 | 150 |
| 2 | ARIS | 22 | 120 |
| 3 | JOHN | 33 | 170 |
| 4 | CHRIS | 22 | 190 |
| 5 | JOE | 55 | 120 |
| 6 | ACE | 11 | 200 |
+----+----------+------+-------+
SHEET2
+----+----------+------+-------+
| ID | NAME |COUNT | PRICE |
+----+----------+------+-------+
| 1 | CHRIS | 13 | 123 |
| 2 | ACE | 26 | 165 |
| 3 | JOE | 39 | 178 |
| 4 | ALFRED | 21 | 198 |
| 5 | JOHN | 58 | 112 |
| 6 | ARIS | 11 | 200 |
+----+----------+------+-------+
The RESULT should look like this in sheet1 :
+------+-------++------+-------+
| JANUARY | FEBRUARY |
+------+-------++------+-------+
+----+----------+------+-------++-------+-------+
| ID | NAME |COUNT | PRICE || COUNT | PRICE |
+----+----------+------+-------++-------+-------+
| 1 | ALFRED | 11 | 150 || 21 | 198 |
| 2 | ARIS | 22 | 120 || 11 | 200 |
| 3 | JOHN | 33 | 170 || 58 | 112 |
| 4 | CHRIS | 22 | 190 || 13 | 123 |
| 5 | JOE | 55 | 120 || 39 | 178 |
| 6 | ACE | 11 | 200 || 26 | 165 |
+----+----------+------+-------++-------+-------+
I need formula in column name "FEBRUARY". this formula will find its match in sheet 2
Assuming the first Count value should go in cell E3 of Sheet1, the following formula would be the usual way of doing it:-
=INDEX(Sheet2!C:C,MATCH($B3,Sheet2!$B:$B,0))
Then the Price (in F3) would be given by
=INDEX(Sheet2!D:D,MATCH($B3,Sheet2!$B:$B,0))
I think this query will work fine for your requirement
SELECT `Sheet1$`.ID,`Sheet1$`.NAME, `Sheet1$`.COUNT AS 'Jan-COUNT',`Sheet1$`.PRICE AS 'Jan-PRICE', `Sheet2$`.COUNT AS 'Feb-COUNT',`Sheet2$`.PRICE AS 'Feb-PRICE'
FROM `C:\Users\Nagendra\Desktop\aaaaa.xlsx`.`Sheet1$` `Sheet1$`, `C:\Users\Nagendra\Desktop\aaaaa.xlsx`.`Sheet2$` `Sheet2$`
WHERE (`Sheet1$`.NAME=`Sheet2$`.NAME)
Provide Actual path insted of
C:\Users\Nagendra\Desktop\aaaaa.xlsx
First you need to know about how to make connection. So refer http://smallbusiness.chron.com/use-sql-statements-ms-excel-41193.html

Resources