Below I was given the following formula to lookup the last transaction in an account (there is a total of 4 accounts) and calculate its current balance based on the transaction of the current row (in this case row 1075). $E$2:$E1074 is the range for the varrying accounts. $F$2:$F1074 is the range of balances associated with each of those accounts. $C1075 is the current transaction we are looking at on row 1075. The error is included in the case that the account in column E does no match an other account in column E and therefore is a new account and the first transaction for that account. This code works.
=IFERROR(LOOKUP(2,1/($E$2:$E1074=$E1075),$F$2:$F1074)-$C1075,-$C1075)
I have experience with vlookup and hlookup but I don't understand the first two sections of this lookup function. specifically the 2 and the 1/($E$2:$E1074=$E1075). I'm not sure what these two values calculate and output to give the desired result. Thank you in advance for your help
Why 2 is for much the same reason as why a "big number" or "big text" (say zzz) can be useful in a MATCH function (that I tried to explain here). Here any number larger than 1 would serve since the objective is to look for what does not exist in order to make the search continue through to the last entry. Returning that last entry, rather than an error for "Not found" may not have been intended - but can be very useful.
Related
I'm working with a data of submission results. Some of data points available: name of submitter, date of processing, and results (approve/reject).
Here is a sample dataset:
Data is sorted by (in this order):
Name of submitter
Submission time of each person, in ascending order (e.g. Andy's 2 entries: first row rejected, second row approved.)
My goal : identify people who has been rejected AND tried submitting again AND eventually got approved.
Or an alternative 'filtering' statement = anyone who has BOTH approved AND rejected submissions.
So when applied to the data sample above::
Both Andy and Evan meets the criteria, since they both have been rejected (could be 1x or >1x), but eventually got approved.
People who got approved in their first try (David), or rejected but never got approved (Bill, Chris), would not be included.
Currently I only could achieve that by eyeballing the dataset, just like one might do on a small dataset such as above. However, I work with 10k+ rows in the actual dataset.
I managed to remove people who only have a single entry (regardless of approved status) since people who meet my criteria would have at least 2 entries.
I used highlight duplicate formula to color the duplicates, sorted the data by cell color, then remove the single entries.
When applied to the sample data above, I got:
My question is: is there a formula that could help me separate the Bills (multiple rejects) from Andys and Evans (people with 1 approve and at least 1 rejects) in a large dataset, without having to eyeball them?
Thank you so much for your help.
Thanks to #Solarmike, found a solution:
Use countifs to calculate the number of approve and rejects for each name.
Then filter out the ones with ApproveCount = 0.
Try below formula
=FILTER(UNIQUE(A2:A10),ArrayFormula(COUNTIFS(A2:A,UNIQUE(A2:A10),B2:B,"Reject")*(COUNTIFS(A2:A,UNIQUE(A2:A10),B2:B,"Approve"))>0))
I need to create a calculated column in Table_Order that would find the next matching, non-blank Customer Status on or after the current Order Date for the current row Customer #.
The tricky part is when there is no matching Customer Status in Table_Ship for a Customer # on a particular Order Date (please see the orange highlights). The match then needs to be on the next matching Ship Date for the Customer # where the Customer Status is not blank.
Please could somebody help me and show me the DAX?
I've spent a long time Googling and have gotten nowhere. I feel like this should be easy!
Also please bear in mind that these tables are massively simplified versions of my actual work, and any suggestion to reorganise the tables or start from scratch won't help me, I need some DAX please!
Thanks in advance!
Phil.
I understand that you have large datasets, but I would recommend you create a FactCustomer table. Here there are the steps I followed with the data you provided.
Create a FactCustomer table
FactCustomer =
DISTINCT ( Table_Ship[Customer #] )
Create a relationship between Table_Ship and FactCustomer and Table_Order and FactCustomer, using Customer # as key.
Create a calculation in Table_Order to find customer status. The calculation makes a lookup (similar to VLOOKUP in excel) to find customer with the same date. This would retrieve the blank for Customer #3, so is neccesary to create a second calculation that would scan Table_Ship for the minimum date without blanks. The final step is using an IF statement to treat blank in the first function, when they are blank, the second formula is used.
Customer Status =
var find_customer = LOOKUPVALUE(Table_Ship[Customer Status],Table_Ship[Ship_Date],[Order Date],Table_Ship[Customer #],[Customer #])
var last_non_blank_date = CALCULATE(min(Table_Ship[Ship_Date]),Table_Ship[Customer Status]<>BLANK())
var find_non_blank = CALCULATE(min(Table_Ship[Customer Status]),filter(Table_Ship,Table_Ship[Ship_Date]=last_non_blank_date))
return if(ISBLANK(find_customer),find_non_blank,find_customer)
The result I get:
I have a great challenge I hope you can help me with.
What I want to achieve:
In the sheetname “Overal campaign information” I have an identical setup to the other sheetnames (for example Week 1 – Email, Week 1 – CPC and so on).
I want to user to first select their week and year and based (under E1) on these to selections, you can select a type that matches that week and year input.
What have I tried?
I have written an INDEX+MATCH that works well, but that is based on a hard coded sheet name and is not dynamic.
I have also tried the INDIRECT function to find information regardless of worksheet name, but failed hard
I have tried to CONCATENATE year+week to get a key to match against point 1, but also not succeeded
Wanted result
Based on the time frame selection (week and year) the type will show available types that matches that input.
Then it will fill in the information in C1:C13 and B17:V:300
Not really clear what you means by "fill in the information in C1:C13". But formula in 'Overal campaign information'!B17 could be
=OFFSET(INDIRECT("'Week "&$F$2&" - " & $F$4&"'!$B$17"),ROW(B17)-17,COLUMN(B17)-2)
This then can be filled into 'Overal campaign information'!B17:V300.
I have an planning exported to Excel which looks like the following (tab ' Data'):
Each production line has a number of people working on it. Now is my goal to show how many people are working on a line per minute. We plan per product group, and several product groups combined form waht a line has to do per minute.
To get the production per minute I created the following (tab 'Conversie'):
=INDEX(Data!$H$2:$H$157;MATCH($N$1&A4;Data!$B$2:$B$157&Data!$C$2:$C$157;1))
In the example it works correct. However, the formula doesn't seem to always return the correct "Artikelomschrijving"(H) every time. I get incorrect return values when I extend this formula to other product groups.
I read that the data needs to be sorted ascending cause I use match_type 1. When I do that I get the right returns for some product groups, but the given example suddenly returns incorrect values.
I can't sort both column C and A in ascending order for the formulas to always return correct items. Can you help me to get past this hurdle?
After a little bit of google translate work, if I'm understanding your question correctly, you need to find the "Item Description" (H) of the record where the "Line" (B) = the value in N1 and the time is between the start and end times.
This is an array formula, you have to confirm it with Ctrl+Shift+Enter
=INDEX(Data!$H$2:$H$157,MATCH(1,(Data!$B$2:$B$157=$N$1)*(Data!$C$2:$C$157<$A2)*(Data!$D$2:$D$157>=$A2),0))
OR with semicolon syntax:
=INDEX(Data!$H$2:$H$157;MATCH(1;(Data!$B$2:$B$157=$N$1)*(Data!$C$2:$C$157<$A2)*(Data!$D$2:$D$157>=$A2);0))
I found the solution, thank you for pointing me in the right direction Valon Miller. This is the formula I fixed it with:
=ALS.FOUT(INDEX(Data!$H$2:$H$154;MATCH(1;(Conversie!L$1=Data!$B$2:$B$154)*((Conversie!$A32>=Data!$C$2:$C$154)*(Conversie!$A32<=Data!$D$2:$D$154));0));"")
Is it possible to parse/cast text (like "=A1+A2") as a formula in MS Excel? I want to build a formula from pieces of text - some of which will only be typed in later by a user.
If the INDIRECT() function did not only work for referencing cells, then I could have typed this =INDIRECT("=A1+A2").
I know you can a work around this problem by simply adding a lot more hidden columns to do sub calculations. But for the sake scalability and efficiency, I would rather do something like the above.
I found a similar questions here and here, yet they don't solve my problem.
The Real-world problem:
Read on for a better understanding as to why you would want to do the above
Scenario
Each item in the list consists of a string, which contains anywhere from 1 to 5 account names each. Each account name is followed by an account number in brackets. The length of the number determines the type of account. Part of the account number is a date, of which the date format depends on the type of account. Further more, each account type may have more that 1 account-number length associated with it, although each number-length[*] is only associated with 1 account type.
Objectives
Extract account-names and their respective account-numbers and account-types from a list.
Make an assumption as to the account-type from the account-number
Validate this assumption by inspecting the build of the number and elements in the name
Check the validity of the account-numbers depending on their type.
The tricky part (this is where my problem lies)
The account-types and their respective account-number-lengths are not known before hand, and are typed into a table by the user of the sheet, specifying a type of account and the number-lengths associated with this account-type. The user should type this into a list - not go and tinker around with delicate formulas
Done so far
Column A: Contains the raw data (each cell has up to 5 names and numbers)
Columns B..F: Each column extracts 1 name, remains empty if all are already extracted
Columns G..K: Each column extracts 1 number corresponding to its name in columns B..F, remains empty if all are already extracted
Columns L..P: Each column calculates the length of the corresponding number in columns
G..K
Now the user would type the following details into a table which assigns certain number-lengths an account type:
TYPE2, BUSINESS, (OR(length=13,length=6))
where length will later be replaced with the cell address which contains the calculated account number-length.
What I want to do now
Columns Q..U:
Should all indicate the account-type of the corresponding account-number in columns G..K. The idea is to build a nested if-elseIf-elseIf formula using the criteria typed in by the user as specified above. Example of one of the elseIF statements:
SUBSTITUTE(CONCATENATE("=IF(",criteria,",",type,",",errCode)),"length","O10"))
All of these elseIf statements will then be concatenated together to form a master formula which will then need to be parsed/cast as a formula to calculate the account-type
This proposal uses only 5 columns (1 for each account-number, containing the master formula) and a table specifying account-types and criteria, also keeping the user away from formulas. Editing 1 line of code (the criteria) will update all formulas. Efficient & Scalable.
Since the user should never tinker around with the formulas under the hood, a simple 1 column if-elseIf-elseIf is out of the question. The alternative to the above would be to make a separate column to test for each account-type for each account-number. Separating/Abstracting out each test to its own column results in much better readability, easier editing & much less debugging - Unless you like multi-screen-wide-formulas. Example: 5 account-numbers * 10 possible account types = 50 extra columns.
Each edit to any criteria needs to copied to 4 other non-adjacent columns and drag-filled down 10,000 rows (columns can not be adjacent since it is effectively a 5x5 array of columns). Not Efficient nor scalable. Unless I'm missing some elegant way of updating non-adjacent formulas in a single click
The rest of the validations error indications are trivial.
Sample data
Tshepo Trust (6901/2005) Marlene Mead (8602250646085)
Great Force Inv 67 Pty Ltd (200602258007)
Jane (870811) Livingstone (6901/2005) Janette Appel (8503250647056) James (900111)
I know all this would probably be much easier to achieve with clever usage of VBA, eliminating all the need to simulate abstraction, encapsulation, multi-dimensional arrays and functional programming on a spreadsheet. But until I can program in VBA, worksheet formulas will be my refuge.
[*]: account number-length could also be described as the amount of digits in the number or as indicated by this formula: LEN(accNumber)
In VBA you have access to Cell.Formula.
I usually used Range to peek a cell by address.
I'm not sure if this would answer your question(it's a very detailed question!), but if your user was entering the account numbers in a table (I'm calling it 'RefTable') , that was:
Length of account number | business type
----------------------------------------
6 | Accountant
8 | Advisor
Then you could just use a vlookup on the length of the account number, given you've already separated them out.
=vlookup(len(accNumber), Reftable, 2, false)
Make sure that you either use a dynamic range name, or specify plenty of space below in RefTable, so that when your users add types, they don't get lost.
Also, if you have two different accounts with the same length, this could get you into trouble.