Täna huvitav Exceli probleem materjaliarvete kohta. Teil on palju toorainet. Iga üksuse võib kokku panna mitmeks erinevaks tipptasemel komplektiks. Kas teil on käes oleva tooraine põhjal piisavalt, et täita teatud eseme tellimus?
Vaata videot
- Tim küsib: kui palju igast esemest on müügil
- Komplitseeriv tegur: üksus koosneb mitmest karbist
- Arve meetod nr 1: lisage abiveerg veerguga INT (vajaminev kogus / käsil)
- Lisage iga toote muutmise korral abimiinimumi vahesummad
- Ahenda vaate # 2 vahesummad
- Valige kõik andmed. Kasutage alt = "" +; jaoks Valige nähtavad lahtrid
- Kleebi uude vahemikku
- Ctrl + H, et muuta Space Min tühiseks
- Mike'i meetod nr 2
- Kopeerige veerg Product paremale ja kasutage käsku Data, Remove Duplicates
- Kasutage ainulaadse toodete loendi kõrval MINIFS-i
- Pange tähele, et MINIFS on saadaval ainult Office 365-s
- Arve meetod nr 3: tavaline pöördtabel ebaõnnestub, kuna arvutatud väljad ei tööta sel juhul.
- Valige oma andmetest üks lahter ja vajutage tabeliks teisendamiseks klahvikombinatsiooni Ctrl + T.
- Selle asemel valige pöördtabeli loomisel ruut Lisa andmemudelisse
- Looge INT-i abil uus müümiseks saadaval olev mõõdik
- Looge MINX-i abil uus müügi jaoks mõeldud komplekt
- See pöördtabel töötab!
- Mike'i meetod nr 4 Kasutage funktsiooni AGGREGATE.
- Näib, et soovite kasutada argumenti MIN, kuid kasutage SMALL, kuna see tegeleb massiividega
- Kasutage
=AGGREGATE(15,6,INT($D$2:$D$141/$C$2:$C$141)/($A$2:$A$141=F2),1)
- AGGREGATE on üks viiest funktsioonist, mis saab massiivi argumendina aktsepteerida ilma klahvikombinatsioonidega Ctrl + Tõst + Enter
- Arve meetod nr 5
- Teisendage andmed tabeliks ja kasutage Power Query - aka Hangi ja muuda
- Arvutage Power Query'is OH / vaja
- Täisarvuks teisendamiseks kasutage funktsiooni Number.RoundDown
- Kasutage rühmitamist tootenumbri ja minimaalse kättesaadavuse järgi
- Sule ja laadige
- Boonus: see on värskendatav!
Video ärakiri
MrExcel: Tere, tere tulemast tagasi, on aeg teise Dueling Exceli Podcasti jaoks. Ma olen Bill Jelen, minuga liitub Mike Girvin Excel Is Funist. See on meie osa 190: mitu komplekti on võimalik müüa?
Hea küll, tänane Tim'i saadetud küsimus. Vaatab meie Dueling Exceli videoid, töötab jaemüüja juures ja palus luua arvutustabeli, et näidata meie müügimeeskonnale, mis meil on ja mida saame müüa. Kõlab lihtsalt, eks? Kuid siin on konks: nende müüdav toode sisaldab mitut karpi ja on inventeeritud ühe kasti kohta. Siin on näide sellest, mida ta näeb. Nii et siin on sellel üksusel P12345 3 erinevat asja, mille nad peavad saatma. Komplektis on vaja 4 1. karpi, 1 2. karpi ja 3. 3. karp. Ja nii palju on neil laos. Hästi, nii et siin lihtsalt matemaatikat tehes on neil 2 komplekti 1. karpi, 4 karpi 2 täielikku komplekti ja 3 karpi 3. komplekti. Kuid see tähendab, et see, mida nad saavad müüa, on nende kolme numbri miinimum - nad saavad müüa ainult 2. Ja siin on neil 4 kasti 4 komplekti,4 kartongist 5, 2 karbist 3, ainult 1 kastist 7 - see on piirav punkt. Nii et sel juhul saavad nad müüa ainult ühte neist. Hästi. Nüüd küsisin hilisemaks päevaks: "Noh, kas on mingit võimalust, et 3. karpi kasutatakse rohkem kui ühes kohas?" Ja ta ütleb: "Jah, aga me muretseme selle pärast hiljem." Hästi.
Nii et siin ma hakkan seda ründama. Ma võin tegelikult välja mõelda mitu erinevat viisi selle ründamiseks, nii et see võib olla huvitav - see võib olla edasi-tagasi tüüpi duell. Mida ma kavatsen teha, on see, et ma tahan, et siin oleks abistaja veerg ja abistaja veerg vaataks üksikute kaupa, kui palju me suudame müüa. Nii = 8 jagatud 4 niimoodi ja me kopeerime selle topeltklõpsamiseks. Oletame, et meil oli vaja 4 ja meil oli 6. Hästi, nii et nüüd öeldakse 1,5. Noh, te ei saa müüa, pool diivanit, eks? Seega peab see olema täisarv. Mida ma siin tegema hakkan, on = INT-- INT, täisarv - see asi, mis võtab kümnendkohad maha ja jätab meile kogu summa. Hästi. Nii et meil on 8 - tagasi algse numbri juurde.
Ja me peame iga siin oleva elemendi jaoks välja selgitama, mis on kõige väiksem arv veerus E? Veenduge, et andmed oleksid sorditud toote järgi, minge vahekaardile Andmed, valige Vahesummad, iga toote muutmise korral kasutage funktsiooni Min. Tead, ma õpetan vahesummasid kogu aeg oma Power Exceli seminaridel ja juhin tähelepanu sellele, et siin on 11 funktsiooni, kuid ma pole kunagi kasutanud midagi muud kui Sum ja Count. Ehkki vahesumma ei pruugi olla kiireim viis seda teha, tahan öelda, et tegelikult oli üks kord, kus sain kasutada midagi muud kui Sum ja Count. Hästi, klõpsake nuppu OK. Ja mida me saame, on iga kord, kui kardina number - tootenumber - muutub, näeme Min. Ja see Min on vastus, mida me tahame. Nii kukkusin vaate number 2 juurde, valin kõik need andmed ja Alt +;ainult nähtavate lahtrite valimiseks, Ctrl + C, ja siis tuleme siia alla ja kleepime - kleepime lihtsalt sellele alale - Ctrl + V. Hästi. Kustutage lisaveerud ja siis peame lahti saama sõnast Min. Ja mitte ainult sõna Min, vaid kosmos Min. Hästi. Nii et kasutan klahve Ctrl + H ja muudan tühiku Min kordumise tühiseks, asendage kõik, klõpsake nuppu OK, klõpsake nuppu Sule ja seal on meie tabel, mida meil on võimalik müüa. Hästi, Mike, ma viskan selle sulle üle.ja seal on meie tabel, mida meil on müümiseks saadaval. Hästi, Mike, ma viskan selle sulle üle.ja seal on meie tabel, mida meil on müümiseks saadaval. Hästi, Mike, ma viskan selle sulle üle.
Mike: Vau! MrExcel, mulle meeldib see. Funktsioon Min vahesummades. Kui lahe see on? Hästi, lähen siin lehele üle, teen sama Helperi veeru. = INT võtame kõik "käsikäes" jagatuna "nõutava kogusega", sulgudes. Ctrl + Enter, topeltklõpsake ja saatke see alla. Nüüd pean lihtsalt leidma antud tingimuse või kriteeriumide jaoks saadaval oleva min. Valin kopeerimiseks toote, Ctrl + Shift + Down Arroe, Ctrl + C, seejärel paremale noolele, Ctrl + V, siis tulen üles ja ütlen käsu Remove Duplicates. Seal see on.
Ma kasutasin kogu aeg täiustatud filtrit, ainult ainulaadseid kirjeid, kuid tundub, et see meetod on kiirem. Seal on minu ainulaadne nimekiri. Nüüd tulen siia. Kui palju? Ja ma hakkan kasutama uut funktsiooni MINIFS. Nüüd on MINIFS Office 365-s; Exceli 2016 või uuema versiooni puhul MINRANGE. Noh, pean sellest veerust leidma minimaalse väärtuse Ctrl + Tõst + Nool alla, F4, koma ja kriteeriumivahemik - see saab olema kogu see toode. Ctrl + Tõst + Nool alla, F4, koma, Vasak nool ja seal me läheme. See saab minimaalse väärtuse sellest, kui paljud sulgevad sulgude, tingimuse või kriteeriumide põhjal, Ctrl + Enter, topeltklõpsake ja saadate selle alla. Hästi. Nii et seal on MINIFS ja vahesumma. Ma viskan selle teile tagasi.
MrExcel: Jah, Mike, väga tore. Eemaldage duplikaadid, hankige ainulaadne toodete loend ja seejärel funktsioon MINIFS. Küsisin talt, mis Exceli versiooni ta kasutab, ta ütles, et Excel 2016. Loodan, et see on 2016. aasta Office 365 versioon, nii et tal on sellele juurdepääs. Kuidas oleks Pivot-tabeliga? Olgu, nii et lõin Pivot-tabeli koos toote ja nõudega, nõutavate koguste summa ja käsikäes olevate summadega. Siis paremalt siit: "Analüüsi", "Väljad, üksused ja komplektid", "Arvutatud väli" ja lõi uue arvutatud välja nimega "Saadaval", mis jagatakse käsil nõutava kogusega - nii ei vaja ma abistaja veerg siin. Esialgu tundus, et see töötab, sest meil on 2, 3 ja 4 ning aruanded, et miinimum on 2 - muutsin selle arvutuse muidugi Miniks,ja see tundus hea.
But then, on this one, where we have 2,4,4,1,2, it's reporting 3. And what's happening is it's doing the calculation on this row. We have 25 on hand, divided by 8, that's 3 and a fraction, and so it's reporting 3, and so, no. A regular Pivot Table calculate item is not going to work. But instead, convert this data to a table and then Insert, PivotTable, Add this data to the Data Model, click OK. And we're going to have, down the left-hand side, Product and what it Requires. I'm going to create two implicit measures here with a Required Quantity and some of On Hand, and then I'm going to create a new measure. So, PowerPivot, Measure, a New Measure, and this new measure will be called Available to Sell (AvailToSell) and that formula is going to be, how many we have on hand divided by how many are required for each item, and click OK. Alright, so 8 divided by 4 is 2.
Alright. Now, that's still not our right answer, and we probably need to run this through the Integer function. So, Measures, Manage Measures, edit this and wrap the whole thing inside the INT function like this, click OK, and click Close. Now we're getting a fractional number-- still the wrong answer here.
But we're going to use a great new function that's only available in DAX. New Measure, and this is going to be called KitAvailable, and the function is not MIN, but MINX-- MINX. The MINX function. And the table that we're going to use is Table 1, and then expression is going to be that Available to Sell that we just calculated, and what this does-- the MINX function evaluates on a row by row basis and finds the minimum error. And so, we'll click KitAvailable, OK. Well, check this out: So here, where we have 2, 4, 4, 1, and 2, it's reporting 1. Alright, now in a perfect world all we have is Product and KitAvailable-- we don't need any of this other stuff in the middle. Alright. So we're just going to check this here, 2, 1, 3, 2, are our answers. I'll take the Requires out, 2, 1, 3, 2, yes. It's going to work. We actually take all the intermediate calculations out, just have a KitAvailable, like that. Mike, do you have another one?
Mike: How cool is that,? You use the MINX function in DAX; well, I'm going to go back over here, I'm going to use a formula. But I'm going to pretend like I don't even have this Helper column. I used MINIFS. Well, before MINIFS, in Excel 2016 there was the AGGREGATE function in Excel 2010. Now I want to use MIN, but of course, functions 1 to 13 do not let you do array formulas. So I'm going to have to use SMALL 1 as a substitute for the MIN function. And SMALL is one of the functions, 14 and above, that can handle array operations. That argument right there, array. So function number 15, comma, I want to ignore divided by zero error, so I'm going to type a 6 to ignore errors, comma, and I need to simulate that whole Helper column in the array argument-- INT. And instead of simply saying On Hand divided by Require, we do the whole column, Ctrl+Shift+Down Arrow, F4, divided by the Required column-- Ctrl+Shift+Down Arrow, F4-- now close parenthesis. That INT right there, if I highlight this and hit F9, it simulates that entire How Many Helper column. Ctrl+Z, now I simply divide it by, in parentheses, I need to get an array of TRUES and FALSEs, so I click on Product, Ctrl+Shift+Down Arrow, F4, and I ask the question are any of you equal to that Product ID, close parentheses. That will give me a bunch of TRUES and FALSEs. F9 TRUES and FALSEs in the denominator, TRUE will become a 1, FALSE will become a 0, which will give us divide by zero error. Ctrl+Z.
In essence, if I click the whole array in here, F9, the divide by zero is going to be our filter, so we only see the numbers for a particular Product. Ctrl+Z, and then, of course, AGGREGATE will pick the min out from that array of errors and numbers, close parenthesis. And AGGREGATE's amazing-- one of five functions that has an argument that can handle array operations without Ctrl+Shift+Enter. So I simply Ctrl+Enter and F2. What did I forget? Backspace. Array, then I type a comma and the K is 1 because I always want SMALL 1, which is the min, close parentheses. Ctrl+Enter, double-click, and send it down, F2. Alright. Aggregate with that whole Helper column right there to get how many for each Product. Alright? I'm going to throw it back over to.
MrExcel: Hey, that's beautiful. I knew there'd be a lot of different ways to solve this. I did not think of using AGGREGATE, which of course is better, because if someone has 2010, this will work. The 15 allows an array out here that is gorgeous. Alright, now, hey, when I set up the question, I just missed this and, you know, and Mike, you know this, when people send us questions, they try and minimize the situation to make it sound like it's easy, but the thing that's going to be a disaster here, is the fact that Carton 3 is used in multiple places, alright? And as soon as they sell something from, let's say, they sell, like, this item P12346, well then the number of Carton 3s on hand is going to change, right? And so that's going to impossibly impact what else we can sell.
Alright. So, thinking about how Tim is going to have to manage this process, he's going to have to have a way to regenerate this item quickly. And so, hopefully, he has an inventory table for every item. It'll show how many there are on hand and then, a VLOOKUP here, to pull the inventory over. Alright? That's what I'm hoping is going to happen, because then it might become somewhat manageable. And if this is something we have to reproduce again and again and again, then Power Query definitely has a use here.
So, Power Query in Excel 2010 or 2013, you're going to go download it, you'll have your own Power Query tab; but in Excel 2016, you're going to look for the Get and Transform. It's funny, in Excel 2016, it was the second group, but then in Office 365 they moved it to be the first group. Power Query has the ability to take something from a Table or Range, so I'm going to choose one cell in this table, Ctrl+T-- that will create a table for me. Table 3 is a fine name, I don't need to rename that. Now, this is the Table, we go to Data, From Table or Range, and we are going to Add a new Column-- this column is going to be a Custom Column, it's going to be called "Available", and that is going to be the On Hand divided by Required Quantity. Alright. Now, we need to send this into the INT function. Unfortunately, the function and Power Query are not the same. So, click here and then go to Formula Types, and you'll find this function is called Number.RoundDown, and this is case sensitive-- you have to make sure to use that exact same case. So =Number.RoundDown, open paren, and closed paren, and click OK. And so 11 divided by 4 is 2.75, rounds down to 2. Alright. That's the answer we need there, we don't need these columns anymore. So I can click on Requires, Shift+click on On Hand, and remove those columns. Alright. Now, choose Product, Transform, Group By, we're going to group by the Product, and the new function is going to be called KitsAvailable, and the operation is going to be the min of the available column. Click OK. Alright.
So now we have Product and KitsAvailable. Home, Close & Load, get a brand new sheet with our answers, but here's the beautiful thing. Alright, so, when we sell something-- let's make these columns less wide-- and we sell, let's say we sell enough so we have no Carton 3s left, I change that number there, the VLOOKUPS bring the results, and then come back here and choose this and Refresh all. And you see that now we have none of this, and this, and this, available to sell, because they all needed that Carton 3, and we have none of those left. Being able to Refresh in Power Query is going to help this in the end.
Well, this was a fun one for me because I knew there would be a lot of different ways to solve this problem. The Episode wrap up of this really long Episode: How many of each item is available to sell? And there's multiple cartons, alright? So, the first thing I did was add a Helper column; and then use Subtotals with the Min function; and then a whole bunch of really boring steps. Make had method number two, used MINIFS, which is great if you have Office 365. I went back to a Pivot Table, but a regular Pivot Table won't work, instead had to do a Data Model and then use the MINX function-- the MINX function-- and that calculated field or measure will actually work. Mike, using the AGGREGATE function, beautiful function, one of five functions that can accept an array as an argument without Ctrl+Shift+Enter. And then, method 5, convert the data to a table and use Power Query, also known as Get & Transform; and we're going to calculate On Hand divided by Needed (Required); and then the Number.RoundDown function to convert to an integer; group by part name, number, and calculate the minimum available; Close & Load; and the bonus, it's refreshable.
Noh, hei, ma tahan tänada teid peatumast, näeme järgmine kord MrExceli ja Excel on lõbus Dueling Exceli Podcast.
Laadige fail alla
Laadige näidisfail alla siit: Duel190.xlsx