Excel - Auto increment value based on string search - excel

I've got a set of data that needs updating to use the same "reference" value (auto-incrementing by .1 with each record found) where a name matches against the first two words.
Please see below for an example table with the desired format required below - is there a way to do this via an automated function in Excel?
Alternatively, I can use SQL Server to do this if easier.
Many thanks in advance
Name
Current Reference
DESIRED Reference
First Name
1001.1
1001.1
First Name Also
2123.1
1001.2
First Name Also With More Text
3456.1
1001.3
Second Name
4567.1
4567.1
Second Name Also
1232.1
4567.2
Second Name Also With More Text & Symbols
5890.1
4567.3

Related

Excel: Create sequential value based on input from multiple drop downs

I am looking for some assistance. I want to be able to generate a name from input on multiple drop down lists of a standardized naming convention and I can not determine how to complete this. As an example this is just data generated for the example. I need to have a value generated by drop down list selections where If the name already existed it would append it to add the next sequential number. Can anyone advise of where I should start with this? I have spend hours searching with no luck.
Currently I have the drop down list selections, that are then matched via INDEX and reference the corresponding code abbreviation in columns F:J, that are then displayed out using =F5&G5&H5&I5&J5".
I can not determine how to add the sequence to this starting with 1, and if 1 already exists moving to 2. Example AAAARE_BSKS1 exists but the same selections are chosen the new name for that selection would be AAAARE_BSKS2.
I was able to get it figured out. I took my generated name, I then added a new column beside it that did a =COUNTIF($J$2:$J26,J26) to find the number of time the name repeated itself prior to this cell. From there I added another column that did a =CONCATENATE(J26:K26) to add the name, with the number of occurrences after, and it worked perfectly. Just wanted to post this in case anyone runs into the same issue. Thank you.

Highlight Specific Word in Associated String and String Variable in Tableau

My goal is to create a highlight function for keywords contained within an associated string, and the overall string variable.
After trying "contains" function, trying variations of the logic contained in these links (1st - https://community.tableau.com/thread/214410, 2nd - https://community.tableau.com/message/846896#846896), and receiving an answer from Tableau Support that they don't know how to highlight keywords contained therein, I wanted to try the Stack OverFlow community before giving up on this one.
To illustrate, below is a table showing my goal with a matrix that contains a keyword and an associated string:
The next shows the ability to select a keyword that is then highlighted within all observations in the string variable:
The closest I have achieved is the following where only the associated string and its entirety are highlighted, as opposed to the broader string variable and just the keyword within the relevant string:
The logic is the following:
Create a parameter for users to enter their search keyword, and create a calculated field to see if the keyword is contained in the Comment field
Create and show a Highlighter for the Comment field.
To use a parameter to call attention to the comment using color:
Create a Parameter called "Search Keyword" with data type string. Select "All" for allowable values.
Create a calculated field called Matches or Color Matches, with the following formula:
CONTAINS([Key Words], [Search Keywords])
OR CONTAINS([Comments], [Search Keywords])
Drag this calculated field onto Color on the Marks card
Right-click the parameter and select "Show Parameter Control
Type the keyword to search and highlight.
To use a Highlighter:
Once the dashboard with keywords and comments has been created, navigate to the options menu for the Comments sheet and select Highlighters > Comments
This now displays a Highlight control which will highlight the row of a comment, instead of changing the text color like the parameter does.
This option will also allow for clicking on keywords, but clicking will only highlight the corresponding comment rather than all comments with the keyword.
As a potential third alternative, if viewers only want to see the matching words and not the entire string, we can modify the parameter method to add an IF statement to the calculated field we created earlier:
IF CONTAINS([Key Words], [Search Keywords])
OR CONTAINS([Comments], [Search Keywords])
THEN [Search Keywords]
END
Do you have any suggestions on how to tweak what I have, or even take a different approach? Any help would be greatly appreciated
As I am sure you know, Tableau is going to colour the entire text string as the CONTAINS condition results in TRUE for the entire string. A different approach could be to restructure your data to a 'long' format with 1 row per word (as below).
Doing this will ensure that Tableau knows each word should be evaluated separately and that the Color Marks Card will partition each word. You can then structure your worksheet like this. To ensure the words are showing in the correct order, you'll need a calculated field to create a unique row (I have called sort_order right("000000" + str([sentence_id]),7) + right("000000" + str([Position]), 7). Note that the Text Marks Card is sorted by sort_order and also that the order in which you drag on/order the Mark Cards is important
The colour_keyword formula then is simply something like [word] = [Keyword Parameter] (maybe check for upper/lowercase variants).
I would recommend maintaining your original table's data structure as well as this 'long table format and link the two datasources via a Relationship (Data > Edit Relationships) and use Dashboard Actions. This would hopefully satisfy your highlight requirements and mean less rework for your other worksheets.
I've published the demo tableau workbook to tableau public here

How to make a fuzzy filter in Power Query according to a list

I want to filter a Power Query table according to another list:
The fact table is:
Location Name
MEL/1F/101 zmel
SHA zsha
BKK/2F zbkk
SGN zsgn
And the lookup list is
{"BKK","SHA"}
The result I want is
Location Name
SHA zsha
BKK/2F zbkk
Now I use
l={"SHA","BKK"},
b=Table.SelectRows(#"Expanded Column1", each List.Contains(l,[location]))
but the BKK/2F is omitted, only SHA shows.
Does any one knows to correct this? Thanks.
You can create a new column using conditional Column by referencing to the table column that contains SHA & BKK. Replace the Column Name to your column.
You can use fill down function if you want to get rid of the nulls.
Update
For your case you might want to use the operator begins with since your BKK has extra text behind

#ReplaceSubstring doesn't display value as expected

I have this formula in one of the columns in my view in Lotus notes database. However, it does not change the value of the field "EmployeeName" in the view and still displays the original name.
Example:
Original value: Franco Martínez, José Ramó
Expected output: Franco Martinez, Jose Ramo
value1:="i";
value2:="e";
value3:="o";
optionList := value1:value2:value3;
aliasList := "í":"é":"ó";
#ReplaceSubstring(#Text(EmployeeName); aliasList; optionList)
As the formula is absolutely correct, the issue has to be somewhere else.
You already checked, that the field is summary, so this cannot be the issue.
Please check the programmatic name of the column (last tab in the properties):
Does it happen to match another column in the same view or is it probably "EmployeeName"? Then just remove the name, it will be repopulated by a new unique name.
Explanation:
Duplicate programmatic names mean, that both columns show the same value, and the formula of the second columnn is never executed. If there is a Fieldname in the name of the column, then it will always show the value of that field, no matter what the formula sais.
Another explanation could be that "í" <> "í"... Probably one of them is the representation of another Unicode- Character and just happens to "look" like the other one... You can check this using a button or agent that just #Prompts the value after replacesubstring, or copy the content of the field into a Hex- Editor...
You could also try the #Ascii() - #Function to convert to ascii without having to replace characters.

Prevent comma-separated list of numbers being interpreted as single large value

33266500,332665100,332665200,332665300 was the original value, cell should look like this: 33266500,332665100,332665200,332665300 but what I see as the cell value in excel is 3.32665E+34
So the question is I want to convert it into the original string. I have found format function on google and I used it like these
format(3.32665E+34,"standard")
giving it as 332,6650,033,266,510,000,000,000
How to parse it or get back the orginal string? I belive format is the function in vba.
Excel has a 15 digit precision limit. If the numbers are already shown like this when you access the file, there is no way to get the number back - you have already lost some digits. VBA code and formulas will not help you.
If this is not the case, you can add a single quote ' mark before the number to store it as text. This will ensure Excel does not try to treat it as a number and thus lose precision.
If you want the value kept exactly, store the data as a string, not as a number. The data type you are using simply doesn't have the ability to do what you are asking it to do.
If you're starting with an Excel file that has already been created then you've already lost the information: Excel has tried to understand what it was given and its best guess has turned out to be wrong. All you can do (if you can't get the source data) is go back to the creator of the Excel file and tell them what's wrong.
If you're starting with, say, a text file that you're importing, then the news is much better:
If you're importing manually using the Text Import Wizard, then at "Step 3 of 3" you need to set "Column Data Format" for the problem field to "Text".
If you're using a macro, you'll need to specify a value for the TextFileColumnDataTypes property that does the same thing. The easiest way to get it right is to use the Macro Recorder.
If you want the four values in the string to be separate cells, then again, look at the Text Import Wizard settings: in Step 1 of 3 you need to set "Delimited" data type (usually the default) and in Step 2 make sure that "Comma" is checked.
The value needs to be entered into the cell as a string. You need to make whatever it is that inserts the value preceed the value with a '.

Resources