I have an excel document with about 12,000 lines of part numbers with pricing information. I think the most intuitive way to sort them would be as follows:
1, 12, 15, 100, 10003, 2, 2002, 20005000, 3, 30, 333, 4, 5, 6, 700000, 800000.
All the numbers that begin with 1 are in the same spot, same with all 2 prefixes, etc. My problem is, excel's default sorting method sorts it like THIS:
1, 20, 30, 40, 100, 150, 200, 250, 500, 1000, 1500, 2000, 10000.
So it sorts them in regular ascending order, which I think makes it more difficult to find your part number, especially as they get super long as some of them do.
I don't have a lot of resources outside of excel at my workspace, so I would like to stick to using that. My knowledge of excel also isn't too impressive, so please treat me like an idiot!
To make thing easier to describe, let's assume that your list of part numbers is in column A, and that you have a blank column B.
In cell B2 enter this formula:
=TEXT(A1,"#")
Copy that down as far as your list goes.
Now, selecting both columns, Custom Sort by column B.
That's it.
Create a new column called SortOrder with the following formula:
=VALUE(LEFT(A2,1))
Then go to Home tab > Sort & Filter > Custom Sort.... Sort first by SortOrder, then by Value:
With data in column A like:
In B1 enter:
=CHAR(1) & A1
and copy down. Then sort cols A & B by B to get:
Is this "alphabetic-style" sort closer to what you need??
Related
I have a column with data that looks like this:
Day
D003
D004
D008
D010
D012
D028
And in the next column, I need to extract just the 3, 4, 10, 12, etc. with NO leading 0's. I tried the following:
=IF(D8="D003 Predose","30",IF(D8="D003 End","31",IF(D8="D003 4hours","34",RIGHT(D8,LEN(D8)-FIND(RIGHT(SUBSTITUTE(D8,"0",""),1),D8)+1))))
Which works for the 4, 5, 8. But for the 12, 17, 21, etc it only gives me the last number. How do I account for the variable length of those strings? I'm really new at Excel and creating formulas "from scratch" so I apologize if the answer is right in front of my nose. If there's a cleaner way to do this, I'm also all ears.
I need to calculate the best 3 marks of class test assignment and get the sum of them in Excel. I am wondering what would be the formula for this. For the reference I have added an image below:
I want among (17, 1, 19, 20) I get (17, 19, 20) and the sum (17+19+20) = 56 put it in final marks column
Since you have only 4 items, it can be calculated like this
=SUM(B3:E3) - MIN(B3:E3)
You can use the LARGE() function to get the largest, second largest, third largest values and sum them all up.
=SUM(LARGE(B3:F3,1),LARGE(B3:F3,2),LARGE(B3:F3,3))
I use this to get best 4 out of 6:
=SUM(LARGE(N4:S4,{1,2,3,4}))
which for your three becomes:
=SUM(LARGE(B3:F3,{1,2,3}))
But I don't enter it as an array formula, works just fine dragged down as necessary.
I select an input on cell L10 using a drop down list.
The values of the list are AH11, AH12, AH13, AH14, AH15 and AH16
Base on this selection, I want to auto populate the value in another cell.
I used the following formula in my target cell
=IF(OR(L10="AH11",L10="AH12"),"6",IF(OR(L10="AH15",L10="AH16"),"18"))
This works because AH11 and AH12 have the same values. Similarly for AH15 and 16.
But AH13 and AH 14 have their unique values.
How do I improve the formula to display values for AH13 and AH14 also?
Just nest the IF's further:
=IF(OR(L10="AH11",L10="AH12"),"6",IF(OR(L10="AH15",L10="AH16"),"18", IF(L10="AH13", "xx", IF(L10="AH14","yy"))))
Build an INDEX/MATCH using array constants instead of cell ranges.
=index({6, 6, 99, 100, 18, 18}, match(L10, {"AH11", "AH12", "AH13", "AH14", "AH15", "AH16"} , 0))
'with these progressive lookup values it can be shortened to,
=index({6, 99, 100, 18}, match(L10, {"AH11", "AH13", "AH14", "AH15"}))
I don't recommend that you return quoted text-that-looks-like-numbers. While there are limited special cases where this is desirable, it is almost always better to leave numbers as true numbers.
I am attempting to count instances of a particular value in Excel, from the last instance of a prior value.
Assume a vertical list starting in cell A1: 1, 2, 3, 4, 5, 4, 5, 3, 4, 5, 2, 3, 4, 3, 4, 2, 3, 4, 5
I can use an array function in, say B14 (A14 value: 3), of {=MAX(ROW($1:14)*(A$1:A14=A14-1)) to give me the row number of the last instance of a "2" (row 10).
I can then have, in C15, a function =COUNTIF(OFFSET(A14,0,0,B14-ROW(A14),1):A14,A14), which will count the instances of 3's since the last 2.
The question is: how do I integrate that array function directly into the final formula, so as not to have to waste a column with the interim calculation?
Edit
The list of numbers represents a level of indentation, so the end result will be a compound of these calculations with different offset checking to provide section numbering: 1; 1.1; 1.1.1, 1.2, 1.2.1, 1.2.2, etc
I want a single function that can calculate this entire depth level, without having to waste several columns identifying how many rows above the previous indent layer was defined.
Try in cell B14 this formula array:
{=COUNTIF(OFFSET($A14,0,0,
MAX(ROW($1:14)*($A$1:$A14=$A14-1))
-ROW($A14),1):$A14,$A14)}
I have the following table & data that can be seen in Excel PowerPivot
item, timeframe, total
1, 1, 15
1, 2, 20
1, 3, 15
2, 1, 10
2, 2, 11
2, 3, 10
While I can easily get the last timeframe, I need to get the previous timeframe's total like:
item, timeframe, total, last_timeframe, last_timeframe_total
1, 1, 15, 0, 0
1, 2, 20, 1, 15
1, 3, 15, 2, 20
2, 1, 10, 0, 0
2, 2, 11, 1, 10
2, 3, 10, 2, 11
I've tried a calculate formula, but that didn't seem to work and only returns blanks. =CALCULATE(SUM(MyTable[total]), MyTable[timeframe] = EARLIER(MyTable[timeframe]) - 1)
EARLIER() doesn't understand any sort of ordering of rows.
EARLIER() refers to nested row contexts.
What you actually want is LOOKUPVALUE() here, which matches the values in specified fields with search criteria you provide, and returns the value that exists for the row which matches those criteria.
Based on your sample it looks like [Timeframe] is a one-incremented index for each item. If this assumption is not true, LOOKUPVALUE() is probably not the function you want.
last_timeframe_total =
LOOKUPVALUE(
MyTable[total]
,MyTable[item] // This is the field we're searching
,MyTable[item] // This is the value to search for in the field
// identified in argument 2 - this evaluates
// in the current row context of the table
// where we are defining last_timeframe_total
// as a calculated column.
,MyTable[timeframe] // The second field we are searching.
,MyTable[timeframe] - 1 // Similar to argument 3.
)
This will give you the value for the prior timeframe for the current item.
Ninja edit: Forgot to mention that Power Pivot isn't really the layer to be doing this sort of work in. Lookups and this sort of data shaping are better done in your ETL from transactional sources. If this is not possible, then it's better done in the query to populate Power Pivot than in Power Pivot. Power Query is a good tool to use for this sort of transformation that easily fits into the Microsoft ecosystem, being another Microsoft add-in for Excel.
Power Pivot is an analytical database optimized for aggregations. In general, if you ever find yourself thinking "for every row," it's a sign that what you're trying to accomplish is probably better suited for a different layer of the BI solution.