How to arrange data by matching values from other cell - sorting

I have a sheet with data wherein one cell data is in arranged but in another column not so I want to arrange data in 3rd column based on 1st column like bellow
Here is my data Column A has arranged data, Column B is unarranged data.
Now I want to arrange data in Column C and In Column D, Column C copy column A and Column D copy Data From Column B but Paste as it is in Column A.
Update --
A | B
-----------------------------------------
1st Name | 3rd Name
_________________________
2nd Name | 1st Name
_______________________
3rd Name | 2nd Name
want to arrange data in column B as data in Column A
A | B
-----------------------------------------
1st Name | 1st Name
_________________________
2nd Name | 2nd Name
_______________________
3rd Name | 3rd Name
Want data like this.

to sort by each column priority-wise:
=SORT(A:D, 1, 1, 2, 0, 3, 1, 4, 1)
to sort C column based on A column:
=ARRAYFORMULA(IFNA(VLOOKUP(A:A, C:D, {1, 2}, 0)))
to sort each column independently:
={SORT(A:A), SORT(B:B, 1, 0), SORT(C:C), SORT(D:D)}

Related

Power Query merge a subset of columns which name fit the criteria

Power Query 2016 standalone
I have a table with columns like this
Market | mapped Brand | mapped Subbrand |
name | text 1 | text 2
I need to concatenate columns that contain a word "mapped" into a new column
I'm trying this:
Text.Combine( List.FindText(Table.ColumnNames(Source), "mapped") , " ")
and get result in every row as a concat of column names
mapped Brand mapped Subbrand
and I need a concat of their values
text 1 text 2
You can create a list of the Columns which contain "mapped", then use that list to select the record fields you wish to combine
ColumnsToCombine = List.Select(Table.ColumnNames(Source), each Text.Contains(_, "mapped")),
#"Add Combined Column" = Table.AddColumn(Source, "Merged", each Text.Combine(Record.FieldValues(Record.SelectFields(_,ColumnsToCombine)),", "))

How to find the average of two columns and having the average(output) in the third column

How to find the average of two columns and having the average(output) in the third column
Column A | Column B | Column C
-------------------------------
1 | 100 | 50.5
1 | 15 | 8
You need to add a new Data-Cell and write the average function by yourself, because Birt supports the average only within one column and not across two columns.
Add a data cell, set the type to decimal and write the average function. You can use the availible column bindings and add them with a double click to your function.

Returning All Column Values From One Selection Within Column

What's the best approach in Parse to return all values of a column based on one item within that column being selected? For example:
Column 1 Column 2
___________________________
a | e
b | f
c | g
d | h
User selects "d" from a UI element, I want to have my app search through this entire class, pinponint "d" and then recognize it is in column 1, then return all values of that column.
Thanks!

How display two fields sums in the same query in HIve

I have a Hive table with the following fields:
id STRING , x STRING
where x can have values such as 'c'.
I need a query that display number of rows where column x contains a value 'c' and the number of rows where x has values are other than 'c'.
id | count(x='c') | count(x<>'c')
---|--------------|--------------
1 | 3 | 7
I don't know if it's possible.
You can try :
SELECT sum(if(x='c',1,0)), sum(if(x!='c',1,0)) FROM table_name;
This will print two columns. I didn't understand the id field in your sample output.

Adding a resetting counter (reset on a column's value change) to a PLSQL line in a view

I am using PL SQL developer and Oracle 11g. Here is my issue:
EDIT
It looks like using rank (partition by header number, line number order by date) works.
I would like to create a counter that changes each time a column has a different value than the last. I need to be able to do this in a view (non-modifiable constraint). The goal would be to use this counter to build a new unique key into that view. Thus, I need to reset the 'counter' each time a line number changes in the planning table (see below).
I have 3 tables. Under each table I have put some important columns:
Header
--headerNumber (unique)
Detail
--headerNumber (not unique)
--lineNumber (unique)
Planning lines
--headerNumber (not unique)
--lineNumber (not unique)
--some date
Into the planning lines table, there exist multiple lines, per line number as well. I want to build into a view (this is a constraint, it must be a view) the ability to build a unique number off of the line number from planning.
Here is some example data:
Header (1 row):
Header Number = 1
Detail (2 rows)
Header Number = 1, LineNumber = 1
Header Number = 1, LineNumber = 2
Planning (4 rows)
Header Number = 1, Line number = 1, date = 01/01/14
Header Number = 1, Line number = 1, date = 01/02/14
Header Number = 1, Line Number = 2, date = 01/01/14
Header Number = 1, Line Number = 2, date = 01/03/14
Into the view I want it to look like this:
HeaderNumber | Line Number | 'Counter' (What I am trying to create)
1 | 1 | 1
1 | 1 | 2
1 | 2 | 1
1 | 2 | 2
Here are some final issues I have faced:
It does not appear as if I can use row number -- The view will contain multiple headers, and more importantly, row number seems to be built out of the entire select's contents -- thus I can't trim it. Row number ends up counting 1,2,3,4 (row above).
Does anyone have an idea about how to build this into a select (to put into a view)? I know this can be done by a procedure but I really need a view.
Regards,
Seriously Confused Man
I'm not sure what you have tried exactly when you say "row number" - do you mean ROWNUM or row_number()?
Doesn't this do what you want?
select headernumber, linenumber,
row_number() over (partition by headernumber order by linenumber)
as counter
from ...;

Resources