I have several thousand rows address data, concatenated in a single field. When i try to sort i get:
103 LOWREY AVE S
104 CHURCHILL DR
104 LOWELL ST N
104 MELROSE ST
105 ALISON AVE
105 ANGELA CRES
105 CARMINE CRES
105 SALTSMAN DR
106 ARGYLE ST N
Is there a way to sort by the street name, then number without breaking apart the data in the single address field?
Sort of, for your example - because each street name is unique, hence sorting by street number would not affect the order anyway:
=ArrayFormula(sort(mid(A1:A9,5,50)))
=SORT(A1:A9,
INDEX(SPLIT(A1:A9," "),,2),1,
A1:A9,1)
SORT A1:A9 on two sort - criterias:
SPLIT Col A by space and choose second column with INDEX
If the street names are same, Sort by A1:A9
Related
I feel like my question should be easy to figure out, but I've looked around and can't seem to find out how to get a basic array spill function that produces the max value. Here's my simplified data set:
Col A
Col B
Apple
864
Carrot
189
Pear
256
Apple
975
Pear
873
Carrot
495
Apple
95
Pear
36
Carrot
804
My objective is to have a unique list of food (from Col A), that returns the max corresponding Value from Col B. The formula for unique list from Col A is easy... =UNIQUE(filter(A:A,A:A<>"")), what I'm struggling with is getting a dynamic maxifs to align with this.
To illustrate, if I put the unique function in cell D2 (thus it would spill to d4 as shown below in blue), a correct corresponding non-array function would be =MAXIFS(B:B,A:A,D2) (shown in column e). I could drag this down the remaining rows but I would like this to be dynamic as there may be more food in my data set in the future.
What I would EXPECT to work is... =filter(MAXIFS(B:B,A:A,D2:D),D2:D<>"") but this returns #Value!. By comparison, if I were to use sumif/Average, =filter(SUMIF(A:A,D2:D,B:B),D2:D<>""), I get what I WOULD expect (which really confuses me).
Is there a way to get a dynamic maxifs (or any function that produces an equal value in column E) that would spill based on unique values in column D?
try:
=QUERY({A:B}, "select Col1,max(Col2) where Col2 is not null group by Col1 label max(Col2)''")
bonus:
=QUERY({A:B}, "select Col1,max(Col2),sum(Col2) where Col2 is not null group by Col1 label max(Col2)'',sum(Col2)''")
bonus 2:
=SORTN(SORT(A1:B, 2, ), 9^9, 2, 1, 1)
2 - sort the second column of range A1:B
<empty> - or 0 or FALSE = "in descending order"
9^9 - output all rows
2 - 2nd mode of SORTN = "group by..."
1 - 1st column
1 - in ascending order
Responding to provide a more clear answer and simplification as others see this looking for same:
The easiest way to accomplish this is by using an array formula such as:
=MAX(IF($A$1:$A$7="Apple",$B$1:$B%7)) followed by CTRL-SHIFT-ENTER
I'm trying to calculate a row value based on the previous row value in the same column within a report expression. I can't precalculate this from database since starting point of calculation is dependent from input parameters and values in a table should be recalculated dynamically within report itself.
In Excel analogical data and formula look like as it is shown below (starting point is always 100):
B C D E
Price PreviousPrice CalcValue Formula
1 NULL NULL 100
2 2.6 2.5 104 B2/C2*D1
3 2.55 2.6 102 B3/C3*D2
4 2.6 2.55 104 B4/C4*D3
5 2.625 2.6 105 B5/C5*D4
6 2.65 2.625 106 B6/C6*D5
7 2.675 2.65 107 B7/C7*D6
I tried to calculate expected values ("CalcValue" is the name of column where expression is set) like this:
=Fields!Price.Value/ PreviousPrice.Value * Previous(reportitems("CalcValue").Value))
but got an error "Aggregate functions can be used only on report items contained in page headers and footers"
Can you please advice whether expected result is achievable in my case and suggest a solution?
Thank you in advance!
Sadly I'm still facing with issue: calculated column does not consider previous calculated value. E.g., I added CalcVal field with 100 as default and tried to calculate using above approach, like: =previous(runningValue(Fields!CalcVal.Value, sum, "DataSet1") ) * Fields!Price.Value/Fields!PreviousPrice.Value.
But in this case it always multiples Fields!Price.Value/Fields!PreviousPrice.Value by 100..
For example CalcVal on Fly always show 200
=previous(runningValue(Fields!CalcVal.Value, sum, "DataSet1")) * 2
https://imgur.com/Wtg3Wsg
I tried with your sample data, here is how I achieved the results
Formula to use, You might have to take care of null values
=Fields!Price.Value/(Fields!PreviousPrice.Value*Previous(Fields!CalcValue.Value))
Edit: Update to answer after Op's comment
CalcValue is caluated with below formula i.e on the fly
=RunningValue(CountDistinct("Tablix6"),Count,"Tablix6"*100
and then Final value as below
=Fields!Price.Value/(Fields!PreviousPrice.Value*
Previous(RunningValue(CountDistinct("Tablix6"),Count,"Tablix6"))*100)
I have explored different solutions suggestions on stackoverflow. Honestly, got a lot of #NUM! , #VALUE! Looks like I really need help on this.
Sharing my effort so far.
A B C
Doc Ref A-Ref
3904 1234 3904
3904 1237 3904-1
3904 1235 3904-2
3907 1110 3907
3907 1111 3907-1
This is the sample data that I'm working on. I'd want to sort 3 columns by descending order (2 numeric cols, Col C is not numeric because of hyphen) by only using excel formula - no VBA or SORT ribbon)
Column D = Rank of Numeric Col A - formula used is =RANK(A2,A$2:A$6)
Column E = Rank of Numeric Col B - formula used is =RANK(B2,B$2:B$E)
On Column C - since it has hyphen, - I may not be able to use RANK
Therefore not sure what will work here - [pthere was a resource about sorting text first 3 letters by desc on stackoverflow, but mine has "spl character hyphen with numbers and so it's text" - that solution won't help me]
Now after RANK, What next?
How can I ensure that Col A is ordered by descending and it's respective Col B entries is turn ordered by descending and therefore Col C.
There will be duplicates on Col A, and at the max Col B.
Col C will be unique (therefore we'll not have to create any intermediate column) but Col C can be blank as well
Please please help!
For non-numerical ranking, you may use COUNTIF.
=COUNTIF($B$2:$B$6,"<="&B2)
Hope this helps..
I'm trying to sort a string field in crystal report that contains numbers and letters
I have:
21B
1
10
11B
33A
11
200
120C
11A
50
120A
1B
and I like to sort it like this: first numeric then letters
1
1B
10
11
11A
11B
21B
33A
50
120A
120C
200
I've tried
if length({Table.field}) = 1 then
"0" + {Table.field})
else if NumericText(right({Table.field}, 1)
then {Table.field}
else "0" + {Table.field}
but it doesn't give me the result I'm looking for
try like below
Create a formula #Sort and write below formula
val({Table.field})
Place the formula in section where you placed fields and supress it. Now sort the records with respect to the created formula.
I have quite a specific data set that I need to store in most compact way as a byte array. It is a live stream of integers that are constantly increasing, often by one, but not always one. Each integer value has a tag that is a byte value. There may be values with same value and tag, but I need to store only distincts. Only supported operations are adding new elements, removal and check if element exists - I keep this data set to check if some pair has been 'seen' recently.
Some sample data:
# | value | tag |
1 | 1000 | 0 |
2 | 1000 | 1 |
3 | 1000 | 2 |
4 | 1001 | 0 |
5 | 1002 | 2 |
6 | 1004 | 1 |
7 | 1004 | 2 |
8 | 1005 | 0 |
As I said this is a live stream, but I can tolerate storing only last few thousands. The goal is to make it as memory efficient as possible in the storage (and in RAM), operations can cost much.
If I had no tags, I could store ranges or values, (1000-1002), (1002-1005) etc, there are usually about 5-6 values in a row without gaps. But the tags mess all this.
My current approach is to encode each value + tag pair in a few bytes - one byte for tag and 1 or more bytes for 'delta' from previous value.
This way I need to store first value, 1000 in above case, and than I store deltas - 0 for #1, #2, 1 for #4, 1 for #5, 2 for #6 etc.
Most deltas are small 1-10, so I can store it in one byte only - first bit is a flag if value is small enough to fit in 7 bits, if not - next 7 bits store a value of how may bytes delta occupies.
Maybe there is a better, more compact, approach?
Since you have only 127 different tag values, you could maintain 127 different tables, one for each tag, thus saving yourself from having to store the tags. In each table you could still use your nifty trick with deltas.
Let the pair (value, tag) where value is a uint32 and tag is a uint8 be a typical item stored in your data structure.
Use an associative array data structure that maps uint32 to an array list of uint16. In C++ terms, the data structure is the following.
std::map<std::uint32_t, std::vector<std::uint16_t>>
Each array list stays sorted with distinct values and never exceeds a size of 216.
Let D be an instance of this data structure. We store (value, tag) in the array list D[value >> 8] as (static_cast<std::uint16_t>(value) << 8) + tag.
The idea is basically that the data is paged. The most-significant 3 bytes of value determine the page, and then the least-significant byte of value and the single byte of tag are stored in the page.
This should exploit the structure of your data very efficiently because, assuming each page is holding many values, you're using 2 bytes per item.