Excel VBA - If two variables are present, cell = this particular value (Not "=IF(AND(" function) - excel

Currently I have a database that has 2 variables:
Fund with an ID attached to it and
Investor with an ID also attached to it.
The example attached, has 4 funds and 4 investors.
An investor can invest in 1 to 4 funds.
I have a VBA function that transposes the data into an "X & Y axis" format.
If there is a name "Ben & Jerry Fund" and "Ben" is present, it should show a quarter entry for that investor name but if the investor does not invest in the fund, it should just be blank.
Question: Is this possible?
Using the =IF(AND( function would not be possible here since there's so many funds and investors in the database.
Figure 1 shows the data reference (before transposing).
Figure 2 is the desired result.

If the purpose is to have a dynamic report. I mean if you want to append more years and avoid operative process. Follow this steeps:
Use "Format as table" for your data. This will allow you to append more data later and it will refresh the functions by itself.
Create a field to extract just the quarter number in the field [Quarter] with =MID([Quarter],1,1)
Create a field to extract the year =RIGHT([Quarter],4) this will allow you to use this field as a filter for future years
Create a pivot table using the new table then organize the data:
*Filter([Year])
*Rows([Fund Name], [Fund Id])
*Columns([Inversor], [Inversor ID])
*Values ([Quarter])
You will see the numbers for the quarter. If you want to see the letter "Q" you can change the format with right click, and select "Number Format...". There in "Custom" change to Q0
Here is a Tutorial about format as table and pivot tables that I made a few months ago. I am sorry it is in Spanish but I am using the Excel English version.

=IFERROR(INDEX($E$3:$E$12,SMALL(IF($C$3:$C$12=L$5,IF($A$3:$A$12=$K7,ROW($A$3:$A$12)-ROW($A$2))),1)),"")
Building an array of row numbers for INDEX and grabbing the first match (smallest row) based on the 2 if statements...

A pivot table can achieve what you want?

Related

Add x Days to a Date Based on vlookup Output Excel

What I'm trying to do is give a due date based on an input date, type of review, and department.
For example if the department is ABC and the review is retrospective, the due date will be the input date + 30 days.
But if the department is ABC and the review is concurrent, then the due date will be input date + 1 day.
I know I can concatenate the department and review into the vlookup table but I'm not so sure how to get the output to be the due date that I want.
Can anyone help?
EDIT:
Per the first answer below, I hashed out an input table with concatenated columns just in case I needed them. It is a bit more complicated than I originally thought.
Input table with date logic
I'd love to simply edit the source data but the report isn't readily available in the database. Could I still use the suggestions below?
Assuming you have a lookup table for the number of days to add depending upon the department and review type similar to the one below, you can use an INDEX/MATCH/MATCH and simply add it to the input date:
=$A2+INDEX($H$4:$J$5,MATCH($B2,$G$4:$G$5,0),MATCH($C2,$H$3:$J$3,0))
SOLUTION FOR AN ALTERNATIVE LOOKUP TABLE LAYOUT
If your layout table is more like as below, you can use a MINIFS formula (or MAXIFS if you would prefer):
=$A2+MINIFS($I$3:$I$8,$G$3:$G$8,$B2,$H$3:$H$8,$C2)

Excel Help - using IF and WORKDAY functions to generate a due date

I am trying to forumlate an IF statement that will generate a due date by taking a given date and adding business days to that dependent on a value in a separate column.
I started off with:
=IF(E3="Fatal",D3+1,IF(E3="Life Threatening",D3+1,IF(E3="Non-Fatal",D3+3,IF(E2="Non-Life Threatening",D3+3,IF(E3="Non-Susar",D3+5,"")))))
But this does not use the WORKDAY or WORKDAY.INT functions at all and is something I am now needing to add. I have collated a list of bank holidays to add into the new function these are listed - 'Backend Sheet (No Edit)'!C1:C752
Example of the sheet is below, I basically need to have it add 1,3,5 business days to the "query received date" dependent on the value in the "seriousness" column and print the new date into the "first attempt due by date" column
Appreciate any help that can be given!
Put your seriousness in a separate helper table along with the days adjustment. Then use workday to find your attempt date.
=workday([date received], index([helper table adjustment],match([this table seriousness],[helper table seriousness],0)),'Backend Sheet (No Edit)'!C1:C752)

Break-Down Data in Excel without VBA (Formula Only)

Many times, I am required to provide some type of break-down to the customers - an example is shown in the attached figure.
I have a table of data ("TABLE DATA" - which is some type of pivot) + Customer provides its official form, its structure must be preserved (highlighted in yellow ). Basically, I need to separate the cost details of CODE "A" and CODE "B" into 2 separated sections.
Customer requires me to provided details for each individual Part (example shows Part A - "Break-Down Part A)
Is there anyway to put a"ITEM" from "TABLE DATA" into Code A and Code B ? the rests can be solved by Vlookup (Price, Quantity) - note: "ITEM" is non-duplicated values . Thank you very much
Number your rows in the breakout using =1 and =A1+1 and then just use the formula ="B-ITEM"&TEXT(A1,"000"). If you want to skip making a counter column you could use ="B-ITEM"&TEXT(ROW()-1,"000") to just use the current row number (minus 1 or however many you need).
If your items aren't sequentially like that, but still unique, I would recommend adding counters on the original tab similar to what you have, which would let you quickly find the 5th A or 7th B, something that counts the previous instances of your current type, and then adds 1. For Row 6 you could do =COUNTIF(A$1:A5,A6)+1.

Error in Calculated Column (using Today) in DataSheet View - Sharepoint 2010

I have calulated column which display's the value based on the difference between today and requested date field.
=Today-[Requested Date]
This is working fine in Sharepoint Standard View. But the same is not working with the datasheet view . The calculated column is showing as below
=#NAME?-[Requested Date].
Due to this i am not able to save the data. Can anyone please let me know how to solve this ?
Which SharePoint version are you using?
I tried the same scenario using SharePoint 2013 and was able to add the values in both standard and datasheet views. I am assuming you might have used the same steps.
Create 2 new columns named RequestedDate(DateTime) and
Today(Single line of text).
Add a new column of type calculated field with formula
=Today-[Requested Date].
Now delete the Today column.
Try entering the data in both the views.
First I have used today() function to calculate difference between 2 days except working days. The list is not automatically updating. If we change the Start_Date, then it calculates and gives the value. Can you suggest me why this happens?
You have mentioned in your post that there is some tricks in using today() function. I have created separate Today_Date column in my list. And Used the same column name in finding difference between 2 days. Here also the same problem exists.
The formula I used is,
=IF(AND((WEEKDAY([Today Date],2))<(WEEKDAY([Release Date],2)),((WEEKDAY([Release Date],2))-(WEEKDAY([Today Date],2)))>1),(((DATEDIF([Release Date],[Today Date],"D")+1))-(FLOOR((DATEDIF([Release Date],[Today Date],"D")+1)/7,1)*2)-2),(((DATEDIF([Release Date],[Today Date],"D")+1))-(FLOOR((DATEDIF([Release Date],[Today Date],"D")+1)/7,1)*2)))
Please tell me how to make the difference between 2 date values update automatically every time I open the list.
Then I tried the trick which you have mentioned above. But it works while I enter the data. When I open the list for the next day or some other day's after the Calculated column is not taking the current day's value, do the data remains same. what should I need to do in case it needs to take current date's value and calculate the formula?

Can I get relational data into an Excel Pivot Table

I have a sheet (let's go with wines as an example) that lists every bottle of wine in my cellar, when I bought it, how much I paid etc.
There's a column that describes the wine in comma-separated tags such as "Fruity, White".
I've created a pivot table from that data, with the description as a filter column. However I can't filter it by "White". I have to find every description that contains "White" such as "Dry, White", "White, Crisp" etc.
Being from an RDBMS background, my natural inclination is to put the tags in their own table keyed against the wine row so there's zero-or-more tag rows per wine row.
How, how on earth can I use that to filter the wine rows?
Yes you can do it within Excel and the description fields can remain as "Dry, White" etc as you do not need to split the comma separated values.
Lets say the Table source comprises a text column for Description, a number column for Value and a number column for Year Bought.
Your pivot is setup with the the following
Fields: Description, Value and Year Bought.
Column labels: Year Bought
Row Labels: Description
Sum of values: Sum of Value
There is a drop down label filter on the row labels - click on this and there should be an option to select Label Filters. Select this and then select Contains. You can enter say "White" which will select all your descriptions that contain white e.g. "Dry, White", "White, Crisp". The filter includes ? to represent a single character and * to represent any series of characters.
There are similar label filters for "begins with" and "ends with" as well as there negation.
I tried this in Excel 2007 and it should also work in 2003. I think in Excel 2003 you could even combine the filters e.g. contains "White" and does not contain "Dry" but in 2007 I could not find a way of doing this.
Forgive me if I'm stating the obvious, but the reason you're having problems here is that the description column is not in 1NF, and the Excel pivot interface isn't flexible enough to allow pattern-based searching.
The simplest option will be to normalise the CSV into a series of columns, each of which represents a single attribute - one column for wine colour, one for sweetness, one for country of origin and so on - and apply the filter across multiple columns. However, if (as your comment on the question suggests) wine is a metaphor for your real problem, you may not have the luxury of revisiting the design of the source data.
Another possibility might be to use a macro (or a database query - I'm not clear from your question whether you have implemented the tag system already) to pre-filter the input data on the pivot table's source sheet based on the tag values you want to search for, then re-refresh the pivot table based on that data.
A third possibility is the VBA used in this question, which looks like it will custom-filter the pivot table's visible rows.
=IF(ISERR(FIND("WHITE",UPPER(B5))),0,1)
create an extra column and add a formula. There are 2 tricks to this. One is to search for WHITE in the description column using upper - to beat the fact that excel find is case sensitive. Two is that it returns a value error if the string does not exist - so iserr will allow you to trap that and return in this example 0 if it doesn't or 1 if it does. You could substitute white and blank for 1 and 0.
you could write a script that loops through the data and adds new lines for each comma separated item in the description column. This would allow the pivot table to filter better.

Resources