Use Table Header as Content In a Cell - excel

I am using the column header titles as the comma separated content in another cell. I am using Excel 2016. I have a table named StudentCourse and for a better illustration please see the below example layout:
[Name] [Math] [Geo] [Bio] [Fees] [Fixes]
Ram Very Bad Good Good Unpaid Urgent: Math, Fees
Dam Neutral Good Bad Paid Urgent: Math, Bio
Rik Good Good Good Paid OK: Not Urgent
Nik Good Good Good Partial Urgent: Fees
The values for the subject columns are from a drop down menu which has the options Good, Neutral, Bad and Very Bad and if the values Neutral, Bad or Very Bad are selected then the Fixes column will be updated with the prefix Urgent: and the column header name (Math, Geo or Fees) depending on what needs to be fixed. If, no fixes are needed then the Fixes column's value will be Ok: Not Urgent.
The Fees column also follows the same concept. Meaning that if the Partial (means partial payment) or unpaid dropdown options are selected for the Fees Column value, then the Fees will be added to the Fixes column. So in short the Fixes column is for easily sorting through what needs to be given special by having the values be automatically selected based on what was chosen for the other columns.
I should also mention that I am new to Excel.

Assuming that the table is located at [A1:E9] and there are no [BLANK] cells as confirmed by OP. Enter this formula in [F2] and copy it to [F3:F9].
Excel 2016
= IF( SUMPRODUCT( ($B2:$E2<>{"Good","Good","Good","Paid"})*1 )=0, "Ok: Not Urgent",
"Urgent: " & SUBSTITUTE(
IF( $B2<>"Good", ", " & $B$1, "" )
& IF( $C2<>"Good", ", " & $C$1, "" )
& IF( $D2<>"Good", ", " & $D$1, "" )
& IF( $E2<>"Paid", ", " & $E$1, "" ), ", ", "", 1 ) )
Excel 2019 (Formula Array)
= IF( SUMPRODUCT( ($B2:$E2<>{"Good","Good","Good","Paid"})*1 )=0, "Ok: Not Urgent",
"Urgent: " &
TEXTJOIN( ", ", TRUE, IF( ($B2:$E2<>{"Good","Good","Good","Paid"}), $B$1:$E$1, TEXT(,) ) ) )
The FormulaArray is entered holding down ctrl+shift+enter simultaneously, the formula would be wrapped within { and } if entered correctly.

If you list the acceptable data in column H:I (as example below). You could use:
=IF(TEXTJOIN(", ",1,IF(INDEX($I$1:$I$4,MATCH($B$1:$E$1,$H$1:$H$4,0))=B2:E2,"",$B$1:$E$1))="","OK: No urgent","Urgent: "&TEXTJOIN(", ",1,IF(INDEX($I$1:$I$4,MATCH($B$1:$E$1,$H$1:$H$4,0))=B2:E2,"",$B$1:$E$1)))

Related

Traslate formula from Excel to DAX( PowerBI)

hope everything is going well for everyone
Look, I have this table and the following excel formula to create a Key for each row on the table.
=CONCAT(IF(LENGTH(Loc.)=1;0;""); Loc.;EXTRACT(Nombre Institución Educativa;SEARCH(" "; Nombre Institución Educativa)+1;3);RIGHT(DANE 12;5);"-";IF(LENGTH(Sitio de Entrega)=1;0;""); Sitio de Entrega)
enter image description here
I need to traslate this formula to DAX (PowerBI), to create a new column called Key1, while import the data from a database. I'm a bit new on this though and I don't know how can I make it works the length, extract and search functions from Excel on DAX.
Thanks in regards if somebody know the answer and can help me
Key1 =
FORMAT ( 'MyTable'[Loc.], "0#" )
& MID (
'MyTable'[Nombre Institución Educativa],
SEARCH ( " ", 'MyTable'[Nombre Institución Educativa] ) + 1,
3
)
& RIGHT ( 'MyTable'[Dane 12], 5 ) & "-"
& FORMAT ( 'MyTable'[Sitio de Entrega], "0#" )
Replace 'MyTable' with your actual table name. The formula does the following:
Pads Loc. with a 0
Gets the first 3 characters after the space in Nombre Institución Educativa
Gets the last 5 characters of Dane 12
Adds a - and pads Sitio de Entrega with a 0
The ampersand concatenates the string

Excel IF statement based on what language excel is sat to, how do i get it to work?

So im using excel to query some data, and based on what language the excel workbook is set to I use this formula.
=IF(INTRO!E6="English";CONCATENATE("'";TEXT(J8;"YYYY-MM-dd");"'");IF(INTRO!E6="Swedish";CONCATENATE("'";TEXT(J8;"ÅÅÅÅ-MM-dd");"NA");"NA"))
When I run it I get the message : unterminated quoted string at or near "2020-07-31NA)";
this is what happens in the vba code to query our pgadmin /postgresql database :
"SELECT * FROM logic.exposure_split(" & datestring & ")"
and the intro!e6 is where the user choose what language of excel they have.
Here's your formula:
=IF(
INTRO!E6="English";
CONCATENATE(
"'";
TEXT(J8;"YYYY-MM-dd");
"'"
);
IF(
INTRO!E6="Swedish";
CONCATENATE(
"'";
TEXT(J8;"ÅÅÅÅ-MM-dd");
"NA"
);
"NA"
) )
If J8 is January 2nd, 2021 then
In English, your formula returns '2021-01-02'
If Swedish, your formula returns '2021-01-02NA with no ending single-quote.
correct code should me:
=IF(INTRO!E6="English";CONCATENATE("'";TEXT(J8;"yyyy-mm-dd");"'");IF(INTRO!E6="Swedish";CONCATENATE("'";TEXT(J8;"ÅÅÅÅ-MM-DD");"'")))

How to reverse comma separated string in Excel?

How can I use a formula in MS Excel to reverse a comma separated sting in row? The number of values are not always same so some rows have 3, 4 and some only one element.
So the output looks like following image
If you have Office 365 Excel then use This array formula:
=TEXTJOIN(",",,TRIM(MID(SUBSTITUTE(A2,",",REPT(" ",99)),((LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1)-ROW($XFD$1:INDEX(XFD:XFD,LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1)))*99+1,99)))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one does not have Office 365 Excel then vba will probably be the only choice.
Sloppy UDF solution:
Function REVERSESTRING(original As Range, delim As String)
Dim i As Long, reversed As String, arr As Variant
arr = Split(original.Value, delim)
For i = UBound(arr) To 0 Step -1
reversed = reversed & arr(i) & ","
Next i
REVERSESTRING = Left(reversed, Len(reversed) - 1)
End Function
A pure single-cell formula works in Excel 365; with that version there is no need for special array calculation entry, VBscripts, or helper columns:
Procedure
Make the following table in Excel:
Add column headings
Select headings, and press the Table icon on the Insert ribbon tab
Copy formula 1 & 2 below into the appropriate columns
Original | # | Reversed
---------+-----+-----------
| {1} | {2}
Place the string you would like to reverse in the first column.
Details and customization
'Original' column
(holds the delimited string value you wish to process)
Place your source data in this column (as seen in the example images)
'#' column
(counts number of items in delimited cell)
Note: (this column is completely optional; it simply shows the number of items in the original column)
{1} <- replace with formula #1:
=LET(
existingDelimiter, ","
, originalValue, [#[Original]]
, SUM(
LEN(originalValue)
- LEN(
SUBSTITUTE(
originalValue
, existingDelimiter
, ""
)
)
)
+1
)
(Note: If your list uses a delimiter other than a comma or if the first column of your table will have a different name, edit the above as appropriate using the same instructions given for formula #2 below.)
'Reversed' column
(reverses order of delimited items in list; optionally changes delimiter)
{2} <- replace with formula #2:
=LET(
existingDelimiter, ","
, newDelimiter, ","
, originalValue, [#[Original]]
, SUBSTITUTE(
ARRAYTOTEXT(
LET(
list,
IFERROR(
FILTERXML(
"<t><s>"
& SUBSTITUTE(
originalValue
,existingDelimiter
,"</s><s>"
)
& "</s></t>"
, "//s"
)
,""
)
,SORTBY(
list,
SEQUENCE(
ROWS(list)
,1
,ROWS(list)
,-1
)
)
)
,0
)
, ", "
, newDelimiter
)
)
Adjust the formula for what you are trying to accomplish by changing the values for existingDelimiter, newDelimiter, and originalValue, as necessary.
A. To reverse a comma-separated string, use the formula as written:
existingDelimiter, ","
, newDelimiter, ","
Example:
B. To reverse DNS names, replace the comma with a period in the definitions for existingDelimiter and newDelimiter:
existingDelimiter, "."
, newDelimiter, "."
This can be very useful for reverse DNS names (aka Java class names / Universal Type Indicators (UTIs) / etc.)
Example:
Replace "Original" in [#[Original]] with the name of your first column, if different.
A. If using just a single cell for input instead of a table column, replace [#[Original]] with the reference to that cell (e.g. B2):
, originalValue, B2
Example:
Explaination of the "Reversed" column formula:
By manually converting to XML, we can use the FilterXML function, which converts the data to an array.
Having the data in an array allows the use of the SortBy function.
SortBy reverses the array by using a helper array created with the Sequence function.
Finally, the ArrayToText functions converts this (now reverse-ordered) array back to a text string that will fit in a single spreadsheet cell.
This is what allows us not to need a loop, helper columns, or VBScript.
Bonus column
To extract a specific term from a list, use the following formula in another table column:
(Change the number in termNumber to the desired value):
=LET(
existingDelimiter, ","
, originalValue, [#[Original]]
, termNumber, "[2]"
, IFERROR(
FILTERXML(
"<t><s>"
& SUBSTITUTE(
originalValue
, existingDelimiter
, "</s><s>"
)
& "</s></t>"
, "//s"
& termNumber
)
, ""
)
)
Example:
Other notes
Needed:
Excel 365 (for at least FilterXML and Let functions, and dynamic arrays) (*)
It might work with other versions but I have not tested those. Please note in the comments if you notice other or future versions (e.g. Excel 2022) work with this.
Not needed:
dynamic array entry
VBscript
macro-enabled files
(*) This can be done without the Let function, but using Let allows the calculation to be edited / repurposed with less chance for user error.
Note: When the Lambda function is released (hopefully later in 2021) then this all can be wrapped up in a named worksheet function
Bonus: to edit more complex Excel formulas with code highlighting (and other features such as auto-intents and folding), try a text editor with Swift programming language support. Examples:
VSCode editor (free; cross-platform)
Until there is an Excel-specific extension available, install a Swift VSCode extension such as this: Swift language VSCode extension (it seems to work quite well to provide code highlighting and folding)
Notepad++ (free; Windows-only)
Select "Swift" from the "Language" menu
Inspired by (apologies if I've forgotten someone):
https://www.howtoexcel.org/tutorials/split-text-by-delimiter/
https://www.sumproduct.com/news/article/have-you-got-what-it-text-introducing-arraytotext-and-valuetotext
https://exceljet.net/formula/reverse-a-list-or-range

Find key word exactly from a text field in Excel

I have a formula below:
=ISNUMBER(SEARCH("Perso",$A2))
I want to it return True for the field that exactly contains my key word "Perso"
However, from the image you can see that both rows return True, because the word "person" also contains "perso".
Can anyone provide some suggestions on how can I achieve my goal in Excel.
Include the deliminating space:
=ISNUMBER(SEARCH(" Perso "," " & $A2 & " "))

Excel Formula with concatenate

I am trying to generate a customer number using the first three letters of the customers last name, the first name initial and middle initial, followed by the last four of their phone number. How would I do this? All I need is the formula.
First_Name Middle_Initial Last_Name Street_Address City State Zip Phone
Nathaniel E. Conn 6196 View Ct Lancing TN 37770 567-273-3956
Something like this (assuming a table with [structured-references], fill in the actual cell names if not):
=LEFT([LastName] & "---", 3)
& LEFT([FirstName] & "-", 1)
& LEFT([MiddleInitial] & "-", 1)
& RIGHT([PhoneNumber] & "----", 4)
I have used dashes ("-") to fill in any spaces where the field might be smaller than the number of characters you need from it. You can change them to any fill character that suits you.
Well, it depends on if each piece of data has its own column, looks like it does.
You can use the left/right functions to parse the data out of your columns.
=CONCATENATE(RIGHT(C1,3) & LEFT(A1,1) & LEFT(B3,1) & RIGHT(H1,4))
I would do:
=MID(CELL_LAST_NAME;1;3)&MID(CELL_FIRST_NAME;1;1)&MID(CELL_MIDDLE_NAME;1;1)&MID(CELL_PHONE;LEN(CELL_PHONE)-3;4)

Resources