How to create sum of list items plus data validation in Google Spreadsheet forumla - sum

I am trying to create sums for each category as I add things to this expense list.
So basically for each category "Brian" "Bobby" "Gas" etc, I want to create a sum. Any suggestions? Thanks in advance for your help. I'm a noob at these spreadsheet formulas...

You should use the SUMIIF() function to sum based on a condition (Reference).
For example: =SUMIF($C:$C, $E:$E=H1) if you want to sum column C based on the category in Column E

Related

SUMIF Conditional based sum

I'll explain whats going on with the left table first:
Qty1 Normal Calculates a sum from another column, Qt2 Normal calculates a product.
The table to the right is supposed to calculate based on an entry in column B, the result in both columns M and N (even when negative).
So basically, no matter where on Column B there will be an entry for "EUR" its suppose to sum Qty1 Normal and Qty2 Normal
I've been spending the last 2.5 hours trying to figure out, trying SUMPRODUCT, IF(SUM( and many other arguments I could try coming up and googling.
The function looks as such:
=SUMIF(B:B,"EUR",(M:M:N:N))
the result should be (826000) and unfortunately I couldn't figure out what is wrong with the function I wrote.
If there is a solution within VBA that will be great, however I believe we can solve this within the simple function regions.
Thank you!!

Minimum amount of Markets for Maximum Products

I am trying to determine what the fewest amount number of markets that render highest amount number of unique products. I'm not sure how to get perform DISTINCT Product Counts with every combination of market.
I can put my data in SQL tables if it's easier with a query.
Here is sample data of what I'm trying to achieve.
Attempting to clarify: Essentially, I'm trying to get all the combination of markets and determine what the distinct count of products are. From there I can derive percentages.
Example:
CHI: 4 DISTINCT PRODUCTS
CHI/LA: 5 DISTINCT PRODUCTS
CHI/LA/MIA: 8 DISTINCT PRODUCTS
To count the unique products for a single market it's a scary formula with curly brackets.
I've setup the formula to work on your sheet so try putting it in cell C2 and press CTRL+SHIFT+ENTER to make it an array formula when you input it.
=SUM(IF(FREQUENCY(IF($E$2:$E$18<>"", IF($E$2:$E$18=B2, MATCH($F$2:$F$18, $F$2:$F$18, 0))), ROW($F$2:$F$18)-ROW($F$1)+1), 1))
You should be able to autofill down to the see the rest of the unique values for the markets you have listed in column B.
Getting the list of markets is complicated but someone asked the question before so check out this answer Creating a list of all possible unique combinations from an array (using VBA)

SQL custom grouping expression based on the field value string Microsoft Visual Studio

I am having a table in BIDS with three columns (e.g. Team, Product Name, Count).
For the Column Product name, I want to apply grouping, that will check for particular string "laptop" and sum all the Product Names containing string "laptop" under Laptops. Values in Product Name may vary, but there is a certain pattern like XX.Laptop.1, YY.Laptop.2 and mix of combinations to laptop.
I need something that will render full list, but add a group over Tablix Group with use of custom expression =IIF(Fields!Product_Name.Value)LIKE "laptop", "Laptops")
Please kindly advice. Thank you
Much thanks Alejandro! here is the result I got after applying your suggestion.
RESULT
I need two additional questions:
If there is a second group I would like to use for grouping - how to add it? (eg. desktops)
How to add a sumary value for the group? Shall it be done over exprerssion?
Thank you
Try using this expression for setting the group by Product Name and to show the Product Name in the respective cell.
=IIF(InStr(Fields!Product_Name.Value,"laptop") > 0,"Laptops",Fields!Product_Name.Value)
If for a specific row the Product Name contains laptop it will group on "Laptops" otherwise it will group by the Product Name value for that row.
UPDATE: If you want to check for another word to create an additional group you can use:
=Switch(
InStr(Fields!Product_Name.Value,"laptop") > 0,"Laptop",
InStr(Fields!Product_Name.Value,"desktop") > 0,"Desktop",
true,Fields!Product_Name.Value
)
Let me know if this helps.

Excel randomly select name from list with multiple entries

I have an excel 2007 worksheet with employee names in column A and total number of entries in column B. I need to be able to randomly select x number of employee names from the total number of entries, allowing for the fact that some will have multiple entries.
For example:
Amy............30
Brian..........12
Charlene.......15
Michael.........1
Nathan..........7
What is the best way to do this?
My initial thoughts are:
1) find the max() of column B occurances of a random number in another column, like C. Then find the top values for all of that new column.
2) create a VBA array of all of the potiential entries and randomly pick one from there.
3) loop through all of the names in column A and create a temp worksheet with column B instances of each, then assign a random num generator and choose the top n.
Having said that, there may be something a lot easier. I am not sure where to begin. Normally I can find code that is similar to what I need, but I am not having any luck. Any help that you can offer would be appreciated.
Thank you in advance.
I would probably do something like this if I understand your question correctly(I just read your question title):

How to create calculated column with data from another list

I have the following situation: List A has two columns (Name, Amount) and in List B (Name) I want to add a calculated column which should be the sum of all entries in List A that have the same name as in List B. Example:
List A:
NAME Amount
L0011 100
L0011 50
L0020 234
So in List B I want the calculated column to show:
NAME Amount
L0011 150
L0020 234
How can this be done? Workflow (as soon as I add/mod an entry in List A, update List B) or something else? Thanks
lem.mallari's answer is a huge pain unless you can assume that the Amounts in List A never change, since it's not tracking whether an item has already been added to the sum. There is no way for a Workflow to iterate through a SharePoint list, which means there is no easy way to calculate the sum or average of multiple list items.
The correct way to implement this will will require some development. The SharePoint Developer Training (2010, 2013) will actually get you most of the way there: an event receiver should trigger when items are added or changed in Lists A and B that uses SharePoint's API to go through List A and average values by Name, then update all (or just affected) items in List B. Alternatively, you can use JavaScript to display the sum of all entries in List A that have the same name as the item in List B as long as all the data is displayed on your page. If you're handy with XPath and InfoPath, you could add List A as a secondary data source to List B's form and select only applicable items in List A to sum from.
But if we're talking Workflows, here's the "workflow only" method. This was tested and successful in 2010. Create custom List C with the following columns:
Title (string, mandatory, enforce unique values)
TotalItems (integer, mandatory, default 0)
Sum (number, decimal places however you want, mandatory, default 0)
Average (calculated, =IF(TotalItems=0,0,Sum/TotalItems)) (optional)
Replace the Name columns in Lists A and B with lookup columns pointing at List C. Delete the Amount column in List B, instead including the Sum column as an additional column. Add the following columns to List A, and ensure that users cannot change them directly. This can be restricted by making InfoPath forms or by making alternative view and edit forms.
AmountArchive (number, identical to Amount, default 0)
AmountHasBeenSubmitted (yes/no, default no)
Create a Workflow to run each time an item is created or modified in List A. Use these commands (I'm using a list for readability; it was getting ugly when formatted as code):
If Current Item:Amount not equals Current Item:AmountArchive
Set Variable:Item Count to (Data source: List C; Field from source: TotalItems; Find the List Item: Field Title; Value: Current Item:Name(Return field as: Lookup Value (as Text)))
Calculate Variable:ItemCount plus 1 (Output to Variable: ItemCount)
Calculate List C:Sum (similar settings as above; be sure to use Lookup Value (as Text) and not String!) minus Current Item:AmountArchive (Output to Variable: SumWithoutValue)
Calculate Variable: SumWithoutValue plus Current Item:Amount (Output to Variable: NewSum)
If Current Item:AmountHasBeenSubmitted equals No
Set AmountHasBeenSubmitted to Yes
Update item in List C (Set TotalItems to Variable:ItemCount; Set Sum to Variable:NewSum; Find the List Item in the same way of Field:Title; Value: Current Item:Name(Return field as: Lookup Value (as Text))
Else
Update item in List C (don't do anything to TotalItems; use the same logic to set Sum to Variable:NewSum)
Set Amount to Current Item:AmountArchive
This can't be done using calculated columns because calculated columns can only be used for columns on the same list.
Using SharePoint Designer Workflows you can just use Create List Item and Update List Item actions so that whenever a user adds a value for L0011 the amount will be added in another list's column which contains the previous amounts already.
Let me know if you need a more detailed answer for the SharePoint approach and I'll provide you a step by step instruction on what to do.
What about using the DSum function? https://support.office.com/en-us/article/DSum-Function-08F8450E-3BF6-45E2-936F-386056E61A32
List B
NAME Amount
L0011 =DSum("[Amount]","List A","[NAME]=''" & [NAME] & "'")
L0020 =DSum("[Amount]","List A","[NAME]=''" & [NAME] & "'")