Function to filter excel table data in to a new dataset based on value defined in another table - excel

I have two tables of data, the first is EmployeeSalaryTbl which holds the salaries for employees over time:
and the second StaffDetailsTbl which has details on the employee discipline etc.
I use various columns from the tables in a function to calculate total employee salaries per month and I'd like to re-purpose the function to only calculate the salaries dependent on a specified discipline in a given cell, for example Progamming.
To do this, I was thinking, is it possible to filter the results of EmployeeSalaryTbl[Employee], EmployeeSalaryTbl[Salary Start Date], EmployeeSalaryTbl[Salary End Date] etc to only contain the rows where the employee has the Programming discipline through a lookup in to the StaffDetailsTbl?

If it doesnt need to be pretty and you just want to sum the totals
You could put this in the column next to your table, starting at the first row you want to check from. then at the bottom sum up the values. You can change where it says programming to make it a cell reference if you want to check for various disciplines
=IF(INDEX(StaffDetailsTbl[Discipline],MATCH(EmployeeSalaryTbl[[#This Row],[Employee]],StaffDetailsTbl[Employee],0))="programming",EmployeeSalaryTbl[[#This Row],[Salary]],"")

Related

Is there a way to match one cell to multiple cells in a second sheet in Excel?

I am trying to calculate order price for a Pizza Place.
I have item prices in one sheet:
And Order number in the other:
I want to match the order number in the two sheets and add the values of price if the order ID is the same in the two sheets.
I have been trying using VLOOKUP to match the values but the match runs only once for the two cells and adds the price of the next cell.
The order table contains the id and the dates and the order_detail table contains the items in the order and their prices.
Here's the Formula i've tried:
=IF(VLOOKUP(A2,order_details!A1:$D$48621,2,FALSE),
VLOOKUP(order_details!$C:$C,Table1[#All],4,FALSE) * order_details!$D:$D)
I looked up the first value in the first two tables with:
=VLOOKUP(A2,order_details!A1:$D$48621,2,FALSE)
Then for the calculation expression I looked up the price in the other table to match the pizza_id in the order table and the pizza_id in the lookup table and return the price and multiplied it with the quantity column in the order table:
=VLOOKUP(order_details!$C:$C,Table1[#All],4,FALSE) * order_details!$D:$D
I simplified this by creating a new column to house item prices in the order details.
Is there an easier way to solve this problem in Power BI? if yes then please share the measure or the column I need to make I have created the relations but I couldn't proceed further so I moved back to Excel.

Create calculated column in one table using data from another table in Spotfire?

Apologies for asking this, I see a few similar questions but unfortunately I don't really understand the answers given. I am fairly new to Spotfire.
I am trying to create a calculated column in one table based off of data from another table. The first table (which I am trying to add the new column to) is a monthly data census of all contracts the company has. Each contract has one row. Call it "monthly table". The second table is a complete transaction history for all contracts, so each contract can have hundreds of rows. Call it "total table".
I am not sure if I can link the data tables. I read in a few similar questions to insert columns from the table with data into the table where the new column will go, or to merge them beforehand, but the monthly table has about 13,000 rows compared to the total table's 550,000, so I am not sure how this would work.
I am trying to create a column to sum all the transaction amounts for each contract if the transaction type (also in the total table) is equal to a certain string. Like a "net transactions to date" column. I successfully created this column in the total table, but then each cell for a contract that meets the conditions had the transaction sum. I want it in the monthly table, where each contract just has one row, and it only displays the sum once. This is the code I have:
IF(
Concatenate([Contract_Number],"(transaction type string)",[Month],Year([Date]))
=[Type],
Sum([Amount]),
NULL)
It is currently in the total table. If possible I would like it in the monthly table, and for the [Number] and [Date] columns to refer to the monthly table, and [Type] and [Amount] to the total table.
Sorry if this is too much information or confusing! Also I know there is a problem with my summation (it is summing all transactions and only displaying in the correct rows, but it needs to only sum correct rows), but I think I can figure that one out, I just need help getting it in the right table.
I am currently working on transitioning a process/workbook from Excel to Spotfire.
If it would help I can provide the current formula used for this process in Excel.
After a few more hours of tinkering, I figured it out! I thought I would explain what I did here in case anyone else encounters a similar conundrum.
TLDR; Made the desired column in the total table, and added the new column to the monthly table with a left single join on the contract number.
My month and date are tied to a document property which is a drop-down of unique date values in my monthly table. Within the total table, I used a similar code to what I've typed above, but instead of referencing the Date column directly, I referenced the document property, so it was pulling the date from the monthly table into the total table. I also switched from the form IF(condition, SUM()) to SUM(IF()) OVER (). This ultimately summed the correct values. For example, there might be five different types of transactions for each contract, but I only wanted the sum of two types. This resulted in the correct sum being displayed. The sum was displayed in every single cell corresponding to the correct contract number in the new column, so (in the same example) in all 5 contract #1 rows, the sum of the two correct types was displayed.
Then, I went to the data canvas for my monthly table, and added the new column. I chose a left single join, as each contract had only one row in the new table, so that the correct sum would only be displayed once.
End result code:
SUM(IF(Concatenate([Contract_Number],"type-string",[Month_ValDt],[Year_ValDt]) =
[Type], [Amount],0)) OVER ([Contract_Number])
Where [Month_ValDt] and [Year_ValDt] are new columns I made in the total table that display the month and ye
ar from the document property that is tied to the date in the monthly table.
Reasoning for the property is that we have a few years of data but I was told to make it dynamic so only one month of data is visible at a time, hence the drop-down.

How to count values in a data range with multiple filters

I need to create a module that will count the amount of values in specified date ranges, with other criteria.
For example, I have a list of products (Products A, B , C, D) in column C, and their sale date in column G.
I need to count all of product A sold before 1/1/1998. I then need to calculate product A sold between 1/1/1998 and 1/1/2005 etc.
I need to be able to run this for all the types of products, and group products together.
E.g. count all of product A & B sold before 1/1/1998.
This has to be done for a new workbook on a weekly basis so ideally needs to be able to be run for a new workbook each week. The tab names always remain the same.
Any help on how to get started would be appreciated
This answer will assume that your dates are entered as excel dates in column G and not a text. You can test this by using the formula =ISNUMBER(G3) where G3 is one of your dates. If it returns true, then your date is properly stored for use by excel formulas and this answer.
=SUMPRODUCT((($C$1:$C$100="A")+($C$1:$C$100="B"))*($G$1:$G$100<Date(1998,1,1))
That is how to hard code it. Personally I would build a table. Each row of the table would be a product you are interested in knowing the count for and a sum of the count would give you combined totals. Repeat the table if you need multiple combinations.
In the following example a single product was counted and then the total for all products listed was the total. The formula for the example in L3 and copied down for each product was:
=SUMPRODUCT(($C$2:$C$9=$J4)*($G$2:$G$9<K4))
The total at the bottom of the table was a simple SUM formula. Because SUMPRODUCT performs array like operations, avoid using full column references and try to restrict it to the data that needs to be checked. Otherwise you may notice a slow down in your system as multiple excess calculations are being perfomed.

Excel - Take Average of Monthly Data

I have a historical data set for commodity pricing. Throughout the data set, the data starts inputting prices on specific days, rather than the average of the entire month. In order to keep the flow of having only the average pricing for the months.
In the best case scenario, I would use an Averageif function, however, the data for each month doesn't display a consistent amount of days.
How can I automate this the process: If the month is the same as the previous row and different than the next row, calculate the average of the ^ rows until you hit the next month.
Here's a simple display of what I mean:
]1
You can use a pivot table to get the output you want. It will also be neatly organized instead of having your averages mixed in with a mostly blank column. Photo below shows the set-up/output of a pivot table generated with random data.
For a solution without pivot tables, you can use the following formula :
=AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0))
The above example is from cell C1, and can be copied down the entire list. The dates are in $A$1:$A$30 and the values in $B$1:$B$30. The first conditions test on the first day of the month (calculated as A1-DAY(A1)+1),and the second condition as last day of the month (calculated as EOMONTH(A1;0)
This will obviously put the average value of the month on each row, but will also work if your data is not sorted on date. If this is the case, and you only want to display one number per month in the column (as in your own example), you can add an additional IF statement wrapped around the formula:
=IF(EOMONTH(A2;0)=EOMONTH(A1;0);"";AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0)))
So it will display empty in all cells, except where the month changes.

Column Name in Pivot table is a day Need to group by month

Good Morning,
New user here; need assistance please. My data is structured with days across a spreadsheet. t1 = 9/30/2016, u1 = 10/1/2016, v1 = 10/2/2016 etc...
The right side of the sheet s1:s711 has structured data which are the specific employee numbers i.e. 5672291. These are unique identifiers and do not repeat.
The data contained between t2:bsa711 represents the amount of sales on a given day for the employee.
I have tried several sumifs and sumproduct functions to capture the amount of sales for each employee by month. This did not work due to the multiple criteria (employees name and <= EOMONTH => EOMONTH criteria to sum the sales within the month)
My last attempt has been to pivot the data and group by month, but I am unable to produce the desired result because I can only get column names (the days) in the pivot list (1000+ due to the T-BSA range of columns/days).
My overall goal is to know the total per month I am not averse to using pivot or some type of array sumifs. Sorry that I do not have much to add to show research. I have been looking.
Thank you in advance.
Make sure the dates are formatted as dates.
Click on analyze -> insert timeline-> select column for dates.
You might want to experience with slicer and pick the days you want which is even more specific.

Resources