How can I get the words in column F to sort according to the frequency shown in column G?
When I try conventional sorting methods, it tells me "You can't change part of an array".
How can I get the words in column F to sort according to the frequency shown in column G?
When I try conventional sorting methods, it tells me "You can't change part of an array".
I would use Power Query with the following Mcode
Your formula produces a comma after each unique item and therefore cannot be matched to the info in Columns A:E as they don't have the trailing comma![]()
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Attribute", "Value"), #"Sorted Rows" = Table.Sort(#"Unpivoted Columns",{{"Value", Order.Ascending}}), #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Attribute"}), #"Grouped Rows" = Table.Group(#"Removed Columns", {"Value"}, {{"Count", each Table.RowCount(_), Int64.Type}}), #"Sorted Rows1" = Table.Sort(#"Grouped Rows",{{"Count", Order.Descending}, {"Value", Order.Ascending}}) in #"Sorted Rows1"
Excel 2016 (Windows) 64 bit
I J 1Value Count 2Advancement 2 3Progress 2 4Accounting 1 5Accounting-manipulation 1 6Address 1 7Administration 1 8Betterment 1 9Blockchain 1 10Cryptography 1 11Development 1 12Digital 1 13Distributed 1 14Encryption 1 15Enhancement 1 16Expansion 1 17Financial-manipulation 1 18Fraud 1 19Growth 1 20Improvement 1 21Insider-trading 1 22Leadership 1 23Ledger 1 24Management 1 25Organization 1 26Public-Key 1 27Securities-fraud 1 28Security 1 29Team 1 30accountability 1 31clarity 1 32disclosure 1 33openness 1 34transparency 1
Sheet: Sheet1
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
Hi @alansidman, thanks for your quick reply.
1) I have been trying for a while to figure out how to make power query work for me with your code, but it looks like I don't know what I am doing (I never used Power Query before). I assumed I was supposed to click on Get Data (Power Query), click "Home" and enter your code in Cell A1 of Query (01). I guess that is wrong, as I can not find any button to execute the code. Very sadly I have had to give up on trying your solution for the time being. But thanks so much for trying to help.
2) You said: "Your formula produces a comma after each unique item and therefore cannot be matched to the info in Columns A:E as they don't have the trailing comma". You are right. I have managed to remove the commas by inserting the "substitute" function in cell F2 as follows:
Old Formula =SORT(UNIQUE(TRANSPOSE(TEXTSPLIT(ARRAYTOTEXT(A2:E8)," "))))
new Formula =SORT(UNIQUE(SUBSTITUTE(TRANSPOSE(TEXTSPLIT(ARRAYTOTEXT(A2:E8)," ")),",","")))
An amended spreadsheet is attached
Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").
It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.
- Follow this link to learn how to install Power Query in Excel 2010 / 2013.
- Follow this link for an introduction to Power Query functionality.
- Follow this link for a video which demonstrates how to use Power Query code provided.
I am not familiar with Mac or if the TOCOL function is available in Office 365 for Mac. If it is you may find this a simpler way to get the sorted unique values. See this in column H of the attached.Formula:
=SORT(UNIQUE(TOCOL($A$2:$E$8,TRUE,)),,1,FALSE)
I have not found a simple formula way of getting the sorted list by frequency. Someone else may be able to help with that. The best I could come up with was this beast. Entered into F2 and copy down.Formula:
=INDEX(SORT(UNIQUE(TOCOL($A$2:$E$8,TRUE,)),,1,FALSE),MATCH(LARGE(COUNTIF($A$2:$E$8,SORT(UNIQUE(TOCOL($A$2:$E$8,TRUE,)),,1,FALSE))-(SEQUENCE(SUMPRODUCT(1/COUNTIF($A$2:$E$8,$A$2:$E$8)),,2)/10^7),ROWS(F$2:F2)),COUNTIF($A$2:$E$8,SORT(UNIQUE(TOCOL($A$2:$E$8,TRUE,)),,1,FALSE))-(SEQUENCE(SUMPRODUCT(1/COUNTIF($A$2:$E$8,$A$2:$E$8)),,2)/10^7),0))
About all I can say for that is that it works although it could be made simpler with 1 or more helper columns.
Last edited by FlameRetired; 03-26-2023 at 07:26 PM. Reason: Corrected mistake in formula.
Dave
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks