I'm looking to auto generate the Fixture ID column and Description Column using several cell values:
The above image includes the required format for both Fixture Id and Description.
Variables for Fixture ID include:
Part Descriptor: Widget Thing = "WT"
Part Length and Strength: 20L = 20" + L strength
Retainer Dimension: 0.75R - 0.75" Retainer
The Description cell simply converts to longer form text with the variables included.
I'm hoping to avoid filling this in manually, but I'm not familiar enough with excel's functions.
This is very difficult to understand your full question considering "Widget Thing" and "WT" are not a part of the base data and only found within the columns you want to automate. So assuming everything is a "Widget Thing", a "Retainer", and a "Spring" this formula will get you started:
Fixture ID
="WT-"&G1:G10&H1:H10&"-"&FIXED(F1:F10,2)&"R"
Description
=G1:G10&""" "&IFS(LEFT(A1:A10,2)="WT","Widget Thing w/ ")&F1:F10&""" Retainer & "&H1:H10&" Spring"
Adjust range as desired, add additional IF parameters if needed.
Related
I am trying to achieve this result: assign a category to a document based on its title, or part of its title.
Title
Category
correspondence
Correspondence
Note Transmission Correspondence
Correspondence
Advisors Evaluation Report
Report
Country Notes
Correspondence
Annual Portfolio Report
Report
Appointment Letter
Correspondence
The categories are arranged into a table (docCategories) where each row starts with a unique category name, and is followed by a set of labels that match entirely or partially with the document title.
Category
Label
Label2
Label3
Label4
Correspondence
Letter
Memo
Note
Correspondence
Report
Dashboard
Report
The formula will take the document title and check if it matches any of the labels (with wild cards), so to return the unique category in the first position in the same row of the matched label.
Appointment Letter -> matches label:letter -> cat:Correspondence
I have made it working with this formula to be copied in the Category column:
=INDEX(docCategories;MIN(IF(docCategories=A2;ROW(docCategories)))-1;MIN(IF(docCategories=A2;1)))
And only if the title is exact matching of the entire label (e.g. Correspondence -> matches label:correspondence -> cat:Correspondence).
I am looking to have it working for matching on part of the title (e.g. Appointment Letter -> matches label:letter -> cat:Correspondence).
I have tried and failed to change the docCategories=<title> into something that can match the substring of the title, even applying the SPLITEXT(<title>) it still fails to give me the expected result.
Who can think of a creative solution for this?
The following solution works for any number of categories and for any number of labels on any category. It also identifies if no labels were found and also if more than one label was found from a different category. Since the question doesn't specify any specific excel version tag I assume Microsoft Office 365 function can be used.
On cell I2 put the following formula:
=LET(rng, A2:E3, texts, G2:G9, lkupValues, B2:E3, categories, INDEX(rng,,1),
BYROW(texts, LAMBDA(text,LET(
reduceResult, REDUCE("",categories, LAMBDA(acc,c, LET(
lkup, XLOOKUP(c,categories, lkupValues), searchLabels, FILTER(lkup, lkup<>0),
IF(SUM(N(ISNUMBER(SEARCH(searchLabels,text))))=0, acc,
IF(acc="", c, "MORE THAN ONE CATEGORY FOUND"))
))), IF(reduceResult<>"", reduceResult, "CATEGORY NOT FOUND")
)))
)
and here is the corresponding output:
The last two rows Title column were added to test the Non-Happy paths.
Explanation
We use LET function to define the names to be used and to avoid repeating the same calculation. If in your excel version you have DROP function available, then the name: lkupValues can be defined as follow: DROP(rng,,1).
The main idea is to iterate over texts values via BYROW and for each text we invoke SEARCH function for all categories. When the first input argument of SEARCH is an array, it returns an array of the same shape indicating the start of the index position of the labels found in text or #VALUE! if no labels were found.
Note: SEARCH is not case sensitive, if that is not the case, then replace it with FIND.
We use REDUCE function to iterate over all categories to find a match. For each category (c) we find the corresponding labels via XLOOKUP. Since not all categories have the same number of labels, for example Report has fewer labels than the Correspondence category. We need to adjust it to remove empty labels. The name searchLabels filters the result to only non-empty labels.
For checking if labels were not found we use the following condition:
SUM(N(ISNUMBER(SEARCH(searchLabels,text))))=0
ISNUMBER converts the SEARCH result to TRUE/FALSE values. N function converts the result to equivalent 0,1 values.
If the condition is TRUE, it returns the accumulator (acc initialized to an empty string). If the condition is FALSE, some labels were found, then it returns the category (c) if acc is empty, i.e. no previous categories were found. If acc is not empty any previous category was found, so it returns MORE THAN ONE CATEGORY FOUND.
Finally, if the result of REDUCE (reduceResult) is an empty string, it means the accumulator was not updated after initialization, so no labels were found for any category and it is indicated with the output: CATEGORY NOT FOUND.
Could someone please assist with helping me create a formula using Power Query that performs the same as the following Excel formula?
=iferror(iferror(if(value(left([Qualifications],1))>0,right([Qualifications],len([Qualifications])-7),""),left([Qualifications],find("/",[Qualifications])-4)),[Qualifications])
Essentially I am trying to strip out expiration dates from a column which contains the qualification title and expiration date (if any) at the end of the title, ideally to just show the qualification title. As some of the qualifications use () in the title, I need to search for the presence of / in the title and remove characters around these.
As I'm new to using Power Query, it's proving a little time consuming trying to learn and understand the different language to Excel!
EDIT - This is the Token Eof error I receive when pasting the provided code:
enter image description here
EDIT 2 - This is the error that is showing in multiple rows, including the row with the date at the end
enter image description here
A powerquery solution .. Assuming you want to remove (##/##/####) then
Paste below into a blank query in home ... advanced editor ... name it RegExReplace and then file .. close and load
/*
https://www.mathscinotes.com/2020/02/power-query-regular-expression-hack/
Mark Biegert
Modified version of regex routine documented by Imke Feldman at
https://www.thebiccountant.com/2018/04/25/regex-in-power-bi-and-power-query-in-excel-with-java-script/
Input Parameter:
x : String to be searched
y : Search regex
z : Replacement regex
*/
(x,y,z)=>
let Source = Web.Page(
"<script>var x="&"'"&x&"'"&";var z="&"'"&z&
"'"&";var y=new RegExp('"&y&"','g');
var b=x.replace(y,z);document.write(b);</script>")
[Data]{0}[Children]{0}[Children]{1}[Text]{0}
in Source
Then in your data to clean, Add column .. custom column .. with formula
= RegExReplace([YourColumnName],"\\(\\d{2}\/\\d{2}\/\\d{4}\\)","")
My problem
I have a list of values (List 1) that have the following pattern...
1234-COD-125
I have another list (List 2), which follow the pattern...
12345(1234-COD-100 - 1234-COD-150)
I need to search List 2 and return True if the value in List 1 is within range. So for example..
List 1 Result List 2
1234-COD-125 TRUE 12345(1234-COD-100 - 1234-COD-150)
1234-COD-126 TRUE 12345(4567-BAH-100 - 4567-BAH-150)
1234-COD-155 FALSE
4567-BAH-125 TRUE
4567-BAH-126 TRUE
4567-BAH-155 FALSE
Background
The first part (1234-COD) is the vendor ID and code. The last part (125) is the order ID. Different vendors can have the same order ID, so my lookup needs to account for the vendor.
What I've done so far
I have written a series of formulas which extract parts of the string. For instance, for
12345(1234-COD-100 - 1234-COD-150)
I have extracted the following in individual cells
100
150
COD
1234-COD-100
1234-COD-150
I know I can create a series to manually populate each order ID within range, then perform a lookup but I have hundreds of values in List 2 so this isn't an option.
Another option is to take the value in List 2 (12345(1234-COD-100 - 1234-COD-150) and check if every number in the range 100-150 is found in List 1.
I would like to be able to use a formula (or even VBA) to achieve this, but haven't been able to get any further. Any help would be greatly appreciated!
Parsing text is always problematic. The following will return what you want:
=SUMPRODUCT((A2>=TRIM(LEFT(MID($C$2:$C$3,FIND("(",$C$2:$C$3)+1,LEN($C$2:$C$3)),FIND(" - ",MID($C$2:$C$3,FIND("(",$C$2:$C$3)+1,LEN($C$2:$C$3)))-1)))*(A2<=SUBSTITUTE(TRIM(MID($C$2:$C$3,FIND(" - ",$C$2:$C$3)+3,LEN($C$2:$C$3))),")","")))>0
But it depends exclusively on the pattern you are showing. Specifically that the range is always in () and the two ranges are separated by -
I am trying to build an excel file to take soil lab test results and organize and assign them preliminary labels.
A sample test will include pH, SAR/ESP, and EC readings. Based on those readings I want to assign the results the label Normal, Saline, Saline-Sodic, or Sodic.
Each label has an associated range of values for each criteria, simplest way to visualize what Im looking for is a a graph with two axis (SAR/ESP vs EC) with 4 quadrants. 3 of the quadrants refer to the same pH range.
I have a simple if then setup going right now that basically assigns each result all the possible labels based on each category then assigns it the label that comes up the most. However this is slow and ugly. Is there a way to consolidate this so that when I import a table where each row is a test I can have one column calculating this?
For example ph is evaluated:
=IF($I$2<=8.5,"A B D","C")
With A = Saline, B = Saline-Sodic, C= Sodic, D = Normal.
Then SAR is evaluated:
=IF($I$3<=13,"A D","B C")
etc.
Then:
=COUNTIF($B$9:$B$12,"A*")
Iterated for each label.
The labels are then counted:
=INDEX(Table1[Column1],MATCH(MAX(Table1[Column3]),Table1[Column3],0))
Working properly:
While automating testing of a website shopping experience, I am attempting to verify that the subtotal, total, and tax are calculating properly. Since the price and/or tax will change in the future, I cannot simply assert the actual price value inside the control. Instead, I would need to build a calculation based upon the controls themselves and assert that quantity multiplied by individual price for each item added together equals the subtotal, and so on.
For example, say my controls for each are named such (control names are in asterisks):
Quantity = *UIItem2Cell*
(InnerText has a Value of 2)
Individual Price = *UIItem249Pane*
(DisplayText has a value of 2.49)
Individual Product Total (price x qty) = *UIItem498Pane*
(InnerText has a Value of 4.98)
Instead of validating the values are the actual numbers, can I write an assertion formula using the identifiers as variables?
Keep in mind, I am using the Coded UI Test Builder rather than writing the code outright.
If the Individual Product Total InnerText assertion comparator is AreEqual, can the Comparison Value be something like:
UIItem2Cell-InnerText * UIItem249Pane-DisplayText
A. Is this sort of formula possible?
B. If so, how do I write it?
(Please forgive me, as I am very green when it comes to this.)
You most certainly can. First off in your app itself it would be greatly useful to use IDs on your controls so you can match on just that criteria. that way your not using calculated values for search criteria.
Now as is in your question you will need to pull those values from the cells, calculate the Value and use it in your Search Criteria
// I'd recommend trimming text values:
// depending on how tables and such are rendered you'll have extra white-space characters
var firstValue = Double.Parse(UIItem2Cell.InnerText.Trim());
var secondValue = Double.Parse(UIItem249Pane.DisplayText.Trim());
var calculatedValue = string.Format("{0,N2}%", firstValue * secondValue);
// assuming your in a web app
var totalDiv = new HtmlDiv(currentHtmlDoc);
totalDiv.SearchProperties.Add(new PropertyExpression(HtmlDiv.PropertyNames.InnerText, calculatedValue, PropertyExpressionOperator.Contains));
Assert.IsTrue(totalDiv.TryFind());
SringAssert.Contains(totalDiv.InnerText,calculatedValue);