I have one excel that contains the demand for each part by city:
e.g: the demand for part a for New york is 100 and 1+7=8 for Atlanta
I have another excel containing the inventory level for two warehouses: rural and urban:
e.g: Warehouse "Rural" stocks 50 for part a and warehouse "Urban" stocks zero for part c.
First I joined these two excels with the demand excel being the primary:
I googled about LOD (level of detail) in order to find out the inventory fulfillment for each warehouse by City
-- count the number of unique parts by each city for the demand:
calculated field [a] = { fixed [City]: countd([Part Number demand]) }
-- count the number of parts that are in stock (inventory level>0) by each warehouse:
calculated field [b] = { fixed [City],[Warehouse Location],[Part Number volume]: countd (if [Inventory Level] > 0 then [Part Number demand] end )}
-- calculate the inventory fulfillment %:
calculated field [c] = calculated field [a] / calculated [b]
and I got the following table and I think it is showing the correct fulfillment % by warehouse for each city: e.g: Warehouse "Rural" stocks 33% of unique parts needed by Atlanta.
Question 1: as I include more part numbers into the excel, I only want to consider the top 10 parts by volume needed for each city. I was trying to do the same thing with LOD to first find the total quantity needed per part per city:
{fixed [City], [Part Number demand]: sum([Part Number volume]) }
But it counts the quantity from both excels and I am just wondering if it is possible to only count the quantity from the primary excel (demand not the inventory),
Question 2: once I could count the total quantity needed, how do I transfer it into a filter so that I could only select top 10 parts by demand.
Apologize if these questions are dumb and appreciate for any advice!!
Related
Excel - I have built a pivot table showing the number of projected transactions. I have changed my screenshot to make it a little easier to understand. I have total projected vehicle sales in a pivot table. I have another section of data which shows how many reps we have for each vehicle type. I have set up a relationship between these 2 objects. I want to create a measure (which I can then add to the pivot table) which divides the various numbers by the rep count... In effect I want each number in the cars section divided by 62, each number in the Trucks section divided by 39, and each number in the Motorcycles section divided by 34.
The code I am using is
=[Distinct Count of Opportunities] / LOOKUPVALUE(Table1[Reps], Table1[Vehicle Type]], [Vehicle Type])
To try to simplify, I am just using the 2nd part of the calculation...
=LOOKUPVALUE(Table1[Reps], Table1[Vehicle Type]], [Vehicle Type])
I am getting the error: The value for Vehicle Type cannot be determined. Either Vehicle Type doesn't exist or there is no current row for a column named 'Vehicle Type'.
What am I doing wrong here?
I have 2 large tables in power pivot and I am trying to reconcile stockpile build grades to crushed stockpile grades. Please see example. I can create pivot table that contains the crushed grades but I am unable to find the right way to bring the stockpile grades though for the reconciliation high lighted in green in the attached example.
Thanks for any help or direction on where to look
In Power Query, create your lookup tables.
1) unique crushers, ID
2) Dates, ID
Here is a function to create a dates table, if you need one. After you invoke the function to get the column of dates, add another column for the ID.
/*--------------------------------------------------------------------------------------------------------------------
PQ Create a Dates Table, returning a single column of dates.
Inputs:
Start Date | Enter the year as yyyy, month as mm, day as dd
End Date | Enter the year as yyyy, month as mm, day as dd
Increments | One row will be returned per increment.
Author: Jenn Ratten
Edits:
07/16/18 | Modified query copied from the internet.
10/01/19 | Converted to a function.
--------------------------------------------------------------------------------------------------------------------*/
let
fDatesTable = (StartYear as number, StartMonth as number, StartDay as number, EndYear as number, EndMonth as number, EndDay as number, IncrementDays as number, IncrementHours as number, IncrementMin as number, IncrementSec as number) as table =>
let
StartDate = #date(StartYear,StartMonth,StartDay),
EndDate = #date(EndYear,EndMonth,EndDay),
Increments = #duration(IncrementDays,IncrementHours,IncrementMin,IncrementSec),
DatesTable = Table.FromColumns({List.Dates(StartDate, Number.From(EndDate) - Number.From(StartDate), Increments)}, type table[Date]),
ChangeType = Table.TransformColumnTypes(DatesTable,{{"Date", type date}})
in
ChangeType
in
fDatesTable
Load all of the tables to the data model.
Go to Power Pivot, diagram view, and create your relationships.
Lookup Crusher to data tables 1 and 2
Lookup Date to data tables 1 and 2
Go to Data View on data tables 1 and 2, add 2 new columns for the lookup IDs. You can specify the column header and the formula at one time by clicking in first cell and using this syntax, then either press enter or click the check mark in the formula bar.
Dates Lookup ID:=RELATED(lookup_dates[ID])
Crusher Lookup ID:=RELATED(lookup_crusher[ID])
Optional, but a good practice....
Right-click the new fields you just created and select "hide from client tools". Also hide the date and crusher fields on both data tables, and the ID field on both lookup tables. When you are creating pivots to summarize data from more than one table, the text fields that you place on your pivot table should be the fields that are shared (aka the lookup tables). This helps to minimize pivots in which the grand totals don't match the sum that you actually see on the table. If you hide the fields, it reminds you of that. There are exceptions of course, but this is a good rule of thumb.
Now create measures to sum the tons and any other math calculations you'd like. With the measures, start simple and let the pivot do the slicing. Put the measures in the values section of the pivot table.
Sum of Source Tons:=sum(Table1[Tons])
Sum of Destination Tons:=sum(Table2[Tons])
I have a table in SSAS tabular mode that shows how individual pieces of products moved through different sections of a production line:
Product_ID, section_ID, Category_id (product category), time_in (when a product entered the section), time_out (when the product exited the section)
This is how the input table looks like:
I would like to write a measure in DAX that can show me the stock of each section and product category day-by-day as shown below by counting the number of distinct product ids which were in a particular section on that day.
I'm using SQL Server 2017 Analysis Services in Tabular Mode and Excel Pivot Table for representation.
Create a new table that has all of the dates that you want to use for your columns. Here's one possibility:
Dates = CALENDAR(MIN(ProductInOut[time_in]), MAX(ProductInOut[time_out]))
Now create a measure that counts rows in your input table satisfying a condition.
ProductCount =
VAR DateColumn = MAX(Dates[Date])
RETURN COUNTROWS(FILTER(ProductInOut,
ProductInOut[time_in] <= DateColumn &&
ProductInOut[time_out] >= DateColumn)) + 0
Now you should be able to set up a pivot table with Category_id on the rows and Dates[Date] on the columns and ProductCount as the values.
I have a table with order records for each Product Type. The columns contain information like Order Number, Customer Name, Product Category, Product, and Order Receipt Date.
My goal is to find the quantity of orders that fall into the below conditions:
New Customers Ordering any Product Category for the First Time
Existing Customers Ordering from any Product Category for the First Time
Reorders from any Product Category
What would be the best way to go about this?
Think I figured it out:
I created two columns for records: "First Product Type Order?" and "First Order?"
"First_Product_Type_Order": IF(AND(Order2=Order1,Product_Type2=Product_Type1),First_Product_Type_Order1,IF(SUMPRODUCT(($Customer$2:$Customer2=D2)*($Product_Type$2:$Product_Type2=Product_Type2))>1,"Reorder","First Time Order"))
"First_Order":
IF(Order2=Order1,First_Order1,IF(SUMPRODUCT(($Customer$2:$Customer2=Customer2)*1)>1,"Existing Customer","New Customer"))
I have this excel sheet and I want to migrate it to Access (in the near future some other DB manager) And I don't know how to normalize it exactly, I know this might be very opinion base. Currently they use this table for inventory
This is the original Table (sheet)
"TableName: Parts", Fields:"Id_Part", "No_Part", "No_Mold", "No_Lot", "Rev", "Description", "Area", "No_Job", No_Batch,"OrderDate","RecivedDate"
Explanation of problem:
ok the idea is to create a DB that stores all the part numbers the "x" company has, these part numbers have the corresponding field:
1.- Id_Part : is the unique number for each part.
2.- No_Part: Number part of each part that the company uses for there products.
3.- No_Mold: Each Part Number uses a Molding Item, some part numbers use the same Molding Item.
4.- No_Lot: The Lot Number is to keep track of the part numbers in case the client has some issues with the final product. (Its like a tracking number).
5.- Rev: is for Revision control example: A, B or C.
6.- Description: Describes the part number.
7.- Area: name of the department in with the part number is used ( like a type of Part Number).
8.-No_Batch: Its similar to the Lot number, but its an internal number for the company.
9.- Order Date: Date in witch we ordered a part number form a provider.
10.- Received Date: Date when we get that part number from the provider.
This is how I tried to Normalize it
Table1 Name: Parts
Fields: Id_Part, No_Part, Id_Mold, Id_Lot, Id_Rev, Id_Description, Id_Area, Id_job,
Id_Batch, Date_Order, Date_Recived.
Table2 Name: Areas
Fields: Id_Area, Name
Table3: Molds
Fields: Id_Mold, No_Mold, Id_Part
Table4:Jobs
Fields: Id_Job, No_Job
Tablr5:Batchs
Fields: Id_Batch, No_Batch
Table6 Name: descriptions
Fields:Id_Description,Description,Id_Part
Table7 Name:Rev
Fields: Id_Rev,Rev,Id_Part
Any help is useful.
It seems like the PartRevision is the main table here rather than the part. You don't order a Honda Accord, you order a 2013 Honda Accord.
You purchase a PartRevision and it goes into a batch and a lot. You sell a part revision and it pulls from a batch and a lot. Here's how I'd set it up.