nested if statment with so many text conditions ERROR - arrays

this is my data table
I'm writing this formula in openoffice not excel, that's why you will see ";" instead of ","
my questions is that I'm trying to put the currency of each country's capital name, and I did it but the thing is that I'm unable to make more than 42 conditions!!!!!
Is there another way or another formula can I use???
Here is the formula I did, and it's working
=IF(D3="AMSTERDAM";"EUR";IF(D3="FRANKFURT";"EUR";IF(D3="OSLO";"NOK";IF(D3="COPENHAGEN";"MULTI";IF(D3="ALICANTE";"EUR";IF(D3="BARCELONA";"EUR";IF(D3="BERLIN TXL";"EUR";IF(D3="VILNIUS";"EUR";IF(D3="BRUSSELS";"EUR";IF(D3="CATANIA";"EUR";IF(D3="DUSSELDORF";"EUR";IF(D3="FARO";"EUR";IF(D3="GRAN CANARIA";"EUR";IF(D3="HELSINKI";"EUR";IF(D3="MALAGA";"EUR";IF(D3="MUNICH";"EUR";IF(D3="PARIS CDG";"EUR";IF(D3="RIGA";"EUR";IF(D3="SANTA CRUZ PALMA";"EUR";IF(D3="SEVILLA";"EUR";IF(D3="TENERIFE";"EUR";IF(D3="BUDAPEST";"HUF";IF(D3="ANTALYA";"TRY";IF(D3="GAZIPASA";"TRY";IF(D3="ISTANBUL";"TRY";IF(D3="BERGEN";"NOK";IF(D3="STAVANGER";"NOK";IF(D3="STAVANGER VIA ESBJERG";"NOK";IF(D3="LONDON CITY";"GBP";IF(D3="LONDON LHR";"GBP";IF(D3="LONDON STN";"GBP";IF(D3="MANCHESTER";"GBP";IF(D3="FUERTEVENTURA";"ISK";IF(D3="LANZAROTE";"ISK";IF(D3="PORTO SANTO";"ISK";IF(D3="GLASGOW";"SCP";IF(D3="GDANSK";"PLN";IF(D3="CLUJ­NAPOCA";"RON";IF(D3="STOCKHOLM";"SEK";IF(D3="PRAGUE";"CZK";""))))))))))))))))))))))))))))))))))))))))

I'd suggest you use a table in another section of your spreadsheet then use VLOOKUP to match the currency to your country.
=VLOOKUP(D3;Currency_Table;2;FALSE}
Which is lookup D3 in the table named Currency_Table and return the exact match (from FALSE) in the second column which will give you your currency.
Or if you want the formula to exist without dependency upon another table you could use something like:
=VLOOKUP(D3;{"AMSTERDAM"\,"EUR";"FRANKFURT"\,"EUR";"OSLO"\,"NOK"; etc...};2;FALSE}
NB: I've added an escape \ before the comma because I'm assuming you are from a language area that uses , as a decimal by your language settings I'm assuming you'll need that in your array for that to work.

Related

How to add values in cells ONLY when other columns contain data from a query result

Link to example file:
https://docs.google.com/spreadsheets/d/1dCQSHWjndejkyyw-chJkBjfHgzEGYoRdXmPTNKu7ykg/edit?usp=sharing
The tab "Source data" contains the data to be used in the query on the tab "Query output". The tab "Desired result" shows what I would like the end result to look like.
The goal I'm trying to achieve is to have the formula in cell A2 on the tab "Query output" to populate the data in all four of the columns, so that it looks exactly like the "Desired result" tab. I know I can get the same result simply by entering additional formulas in C2 and D2, but this is not the objective, I need the results to come specifically from the single formula in A2.
The information in the "Additional data 1" column should simply repeat the word "Test" for every row that contains data in the first two columns. The information in the "Additional data 2" column should simply repeat the data from cell 'Source data'!A1 for every row that contains data in the first two columns.
Please feel free to edit the example file as it only contains dummy data. If you like, you can copy the tab "Query output" to create your own working formula for illustrative purposes.
EDIT:
I'm thinking along the lines of creating an array that consists of the required data for the columns "Additional data 1" and "Additional data 2" and then combining that array with the array of the query result which provides the first two columns. I've been experimenting with this in various ways, but so far the only result I have achieved is an error on the first cell of the query results. I also have no idea yet how I could make sure that the second array contains an equal amount of rows to the query result.
You can add static data into query:
=QUERY('Source data'!A3:B,"SELECT A,B, 'Test', '" & 'Source data'!A1 &"' WHERE A IS NOT NULL LABEL A '', B '', 'Test' '', '" & 'Source data'!A1 &"' ''")
Many thanks to #basic for the provided assistance! The insights were a great help to solving my issue. That said, I have muddled along a bit, and I've come up with a slightly different solution which I find better suited as it gives true blank values instead of a column filled with spaces.
First of all, instead of querying directly on the source data, I built an array and queried on that. I used the two existing columns (A and B) from the source data and added a third column to the array which does not exist in the source data. In order to make sure that the third column would consist of blank values, I used the IFERROR formula.
=IFERROR(0/0)
The formula above returns a blank because dividing by zero forces an error and the IFERROR method returns a blank unless an alternative return value is specified.
In order to be able to use this formula in an array however, it had to be tweaked slightly, because as it is it would only return a single blank cell value instead of a column of blank values. To do this, I used an already existing column from the source data, and then encapsulated it in an ARRAYFORMULA.
=ARRAYFORMULA(IFERROR('Source data'!A3:A/0))
Using this, the resulting array has the following formula.
=ARRAYFORMULA({'Source data'!A3:A,'Source data'!B3:B,IFERROR('Source data'!A3:A/0)})
This creates an array consisting of the two original columns A and B from the source data, plus an additional third column filled with blank values. This array can now be queried upon, and using the tricks previously provided by #basic the desired result as specified in the original question can be achieved.
Due to the query now being used upon a user-defined array, the columns in the SELECT statement now have to be referred to as Col1, Col2, Col3, instead of A, B, C. The final formula now looks like this.
=QUERY(ARRAYFORMULA({'Source data'!A3:A,'Source data'!B3:B,IFERROR('Source data'!A3:A/0)}),"SELECT Col1,Col2,'Test',Col3,'"&'Source data'!A1&"' WHERE Col1 IS NOT NULL LABEL 'Test' '','"&'Source data'!A1&"' ''")
I hope this information may prove of use to someone else as well.

How do I get value of an indirect formula into a format that can go into an array?

My Google Sheet that will be updated over time with new sheets. On my dashboard/master sheet, I can write a simple INDIRECT that will pull information from a cell in the sheets. However, the formula does not replicate its way down the column. I understand that I need to use an ARRAYFORMULA to get the auto formula placement done.
I've tried many ways but the one that I think may get me there is to use CONCAT. My columns look like this:
Event Title [uses a script to pull in the names of all the sheets]
Use an array to get the titles so they pre-poluate down the column so I can use it later: =ARRAYFORMULA(IF(Row(A:A)=1,"Get Title from A",IF(ISBLANK(A:A),"",A:A)))
-- The Event Title is now appearing as plain text in Column B.
I then use CONCAT to write the part of the formula I need to help get the name of the INDIRECT in without using the INDIRECT formula.
=CONCAT("'"&B5&"'"&CHAR(38)&"!"&"""","B2"&"""")
-- This gets me this result: 'Computers 101'&"B2"
At this point, my hope is that I could then use this information ('Computers 101'&"B2") into an ARRAYFORMULA. I used this formula to try and do that:
={"Event Date";ARRAYFORMULA(A6:A+D6:D&"Cat")}
-- I get the answer: 0
The expected value was the date cell (B2) in the Computers 101 sheet. Any ideas how to proceed? I don't know the names of the sheets in advance.
unfortunately, this is not possible within of scope of google sheets formula. if you need ranges from other than the actual sheet you need to use INDIRECT which is not supported under ARRAYFORMULA.
you have 3 options:
hardcode it like: https://stackoverflow.com/a/68446758/5632629 with IFERROR & array of empty cells to match columns of your range
generate formula which will generate your final formula/range as a text string and then use a simple script to convert that string into the valid formula: https://stackoverflow.com/a/61819704/5632629
do it all with scripts

How to return an array matching a certain criteria in Excel?

I'm trying to parse an XML file in Excel, which is a Japanese dictionary. It contains several translations of each entry into different languages, and some entries have multiple translations per language. I want to write a formula that finds all of the translations by their language code, returns them as an array, and concatenates them using a TEXTJOIN formula. But I don't know how to go about this in Excel.
In Google Sheets, this would be easily solved by a FILTER function, but I can't use Sheets as there's too much data, and I haven't managed to get access to the beta FILTER function yet.
In the below picture, I'm trying to return the values in the <gloss xml:lang*> column, by searching for the values in the lang column. So for example, I want to return all values which have a "dut" next to them, and concatenate those into a single line using TEXTJOIN.
Any idea how I could go about doing this?
I fixed this by downloading the FILTER function. This is part of the Office Insider program, which releases Beta features if you choose to participate. You can access the Insider program by going to File > Account > Office Insider. Then to update your Office version go to File > Account > Office Updates to install the Insider update.
To filter the list by the "lang" column the formula looked like:
=FILTER([range in H column], [range in I column]=T$2)
I haven't specified either range because I used a formula-defined range using the INDIRECT function to avoid filtering through a million rows. The H range is what I want in the results of the filter, the I range is what I want to filter by - the "lang" code. T$2 represents the "lang" code, in this case "dut", and when I copy it across it will filter by each of the 8 lang codes in Row 2.
Then I used TEXTJOIN to combine it the array result into one column using the comma separator:
=TEXTJOIN(", ", TRUE, FILTER(...))

SSRS Format Numeric not summarizing in excel

I need to set a format for a column when the column "KPI" has a value with '%' I need that the value has the format for a percentage otherwise the currency format, so I have something like this:
=IIF(InStr(Fields!KPI.Value,"%")>0,Format(Fields!DIA.Value, "P"),Format(Fields!DIA.Value, "C"))
That expression works properly, but when I try to export that report to excel, that column is not summarizing when I select several columns as you will see in this picture:
As you can see excel is recounting but not summarizing, I have tried formatting each field from SQL Server and with this formula:
=IIF(InStr(Fields!KPI.Value,"%")>0,Format(Fields!DIA.Value, "###.#%"),Format(Fields!DIA.Value, "###,###,###,###.##"))
But the same happend when I export that report to excel, is there another way to handle this?
In order to make sure that Excel interprets a value as numeric, you can use the RenderFormat global variable to detect when the report is being rendered for Excel and not include the problematic formatting characters:
=IIF(InStr(Fields!KPI.Value,"%")>0,Format(Fields!DIA.Value, "###.#%"),IIF(OR(Globals!RenderFormat.Name="EXCELOPENXML",Gl‌​obals!RenderFormat.N‌​ame="EXCEL"),Fields!‌​DIA.Value,Format(Fie‌​lds!DIA.Value, "###,###,###,###.##")))
If its critical that you display a thousands separator in your generated output you can use the Language global variable to detect the user's region and use the appropriate character. That check would take the general form Globals.Lanuage="en-US", depending on what particular regions are involved.
Here's an example of using the RenderFormat.Name variable to check the renderer in VS2013:
When doing a preview of the report, the format will show that the render type is RPL:

Database access excel formatting or if statement or grouping

I have a database formatting problem in which I am trying to concatenate column "B" rows based on column "A" rows. Like So:
https://docs.google.com/spreadsheet/ccc?key=0Am8J-Fv99YModE5Va3hLSFdnU0RibmQwNVFNelJCWHc
Sorry I couldn't post a picture. I don't have enough reputation points YET. I'LL Get them eventually though
So I'd like to solve this problem within Excel or Access. Its currently an access database, but I can export it to excel easily. As you can see, I want to find "userid" in column A and where there are multiple column A's such as "shawn" I'd like to combine the multiple instances of shawn and concatenate property num as such.
Even though there are multiple instances of column A still, I could just filter all unique instances of the table later. My concern is how to concatenate column B with a "|" in the middle if column A has multiple instances.
This is just a segment of my data (There is a lot more), so I would be very thankful for your help.
The pseudo code in my head so far is:
If( Column A has more than one instance)
Then Concatenate(Column B with "#"+ "|" +"#")
I'm also wondering if there is a way to do this on access with grouping.
Well Anyways, PLEASE HELP.
In excel we can achieve it easily by custom function in vba module. Hopefully using vba(Macros) is not an issue for you.
Here is the code for the function which can be added in vba. (Press Alt+F11, this will take you to visual editor, right click the project and add a module. Add the below code in module)
Public Function ConcatenatePipe(ByVal lst As Range, ByVal values As Range, ByVal name As Range) As String
ConcatenatePipe = ""
Dim i As Integer
For i = 1 To lst.Count
If name.Value = lst.Item(i).Value Then ConcatenatePipe = ConcatenatePipe & "|" & values.Item(i).Value
Next
ConcatenatePipe = Mid(ConcatenatePipe, 2)
End Function
This function you can use in excel in F Column of your example. Copy the below formulla in F2 and the copy paste the cell to rest of F column. =ConcatenatePipe($A$2:$A$20,$B$2:$B$20,E2)
I believe you can solve this with an SQL GROUP BY function. At least, here's how I'd do it in MySQL or similar:
SELECT userid, GROUP_CONCAT(propertynum SEPARATOR '|') FROM Names GROUP BY userid
as described in this stack overflow post: How to use GROUP BY to concatenate strings in MySQL?
Here's a link on how to use SQL in MS Access: http://www.igetit.net/newsletters/Y03_10/SQLInAccess.aspx
Unfortunately there is not a GROUP_CONCAT function in MSAccess, but this other SO post explains some ways round that: is there a group_concat function in ms-access?

Resources