I am creating a cycle count sheet. Sheet 1 will be user input where the material and quantity found will be put. Sheet 2 is a snapshot of inventory at the time of the count. I want the quantity of the material found to be distributed among the quantities on sheet 2 until the sheet 1 quantity is exhausted. It would also be helpful to distribute the quantity in order of the newest batch(day code) to the oldest batch(FIFO).
I can make this work when only looking at one material at a time with MIN MAX functions. The trouble I am having is when I add criteria. I have attached a screen shot of the desired results. As you can see, an ideal formula in D11 Found that 30,000 of P9919617 was available on 'sheet 1' and distributed that amount through inventory on 'sheet 2' until the 30,000 was exhausted leaving an adjustment of 10,584 to the 2278US9602 Batch.
I have attached a link to the sheet below as well.
https://docs.google.com/spreadsheets/d/1RsmNMZS6yy7ayWs0cdYJlWyqTCgdieNXLB9sancsg0Y/edit?usp=sharing
try:
=INDEX(LAMBDA(Q, A, S, IFERROR(IF((COUNTIFS(A, A, ROW(A), ">="&ROW(A))=1)*(VLOOKUP(A, S, 2, )<>""),
VLOOKUP(A, QUERY({Q, VLOOKUP(INDEX(Q,,1), S, 2, )}, "select Col1,Col2-Col3"), 2, ), 0)))
(QUERY(A2:C, "select A,sum(C) group by A"), A2:A, Sheet1!A:B))
UPDATE:
=INDEX(LAMBDA(p, LAMBDA(r, LAMBDA(u, LAMBDA(s, t, w,
IFNA(IF(s<>"", s, IF(t<>"", t, w))))
(IF(r<0, 0, ), IF(COUNTIFS(p, p, r, ">0", ROW(p), "<="&ROW(p))=1, r, ),
u-ARRAY_CONSTRAIN({""; u}, ROWS(u), 1)))
(IF(COUNTIFS(p, p, r, ">0", ROW(p), "<="&ROW(p))>0, r, )))
(MMULT(1*TRANSPOSE(IF((TRANSPOSE(ROW(p))>=
ROW(p))*(p=TRANSPOSE(p)), OFFSET(p,,2), 0)), ROW(p)^0)-VLOOKUP(p, Sheet1!A:B, 2, )))
(A2:INDEX(A:A, MAX(ROW(A:A)*(A:A<>"")))))
step-by-step formula explanation
Related
I was able to find the “2”'s per client with the following formula (Column L).
TotalSimultaneous2 =
IF(Data[Column1]=2,1,0)+
IF(Data[Column2]=2,1,0)+
IF(Data[Column3]=2,1,0)+
IF(Data[Column4]=2,1,0)+
IF(Data[Column5]=2,1,0)+
IF(Data[Column6]=2,1,0)+
IF(Data[Column7]=2,1,0)+
IF(Data[Column8]=2,1,0)+
IF(Data[Column9]=2,1,0)+
IF(Data[Column10]=2,1,0)
Now I need help finding the total amount of columns that contain at least one “2” column N.
In the example below, it would be 7, and that number is coming from the count of all the columns in green since they have at least one “2”.
I can find the simultaneous one. For example, Client4 has the max amount of “2” at the same time, which is 6, but I am having a hard time adding that one “2” from Column10 from Client10 and showing that the number of columns containing a “2” is 7 instead of 6.
Anything helps. Feel free to ask for further clarification, and I will try my best.
You can try this below measure. Here I have added 3 columns but you can add as many as you have-
count_column_with_2 =
CALCULATE(
DISTINCTCOUNT(your_table_name[col1]),
FILTER(your_table_name, your_table_name[col1] = 2)
)
+
CALCULATE(
DISTINCTCOUNT(your_table_name[col2]),
FILTER(your_table_name, your_table_name[col2] = 2)
)
+
CALCULATE(
DISTINCTCOUNT(your_table_name[col3]),
FILTER(your_table_name, your_table_name[col3] = 2)
)
quick question:
I have a total amount that is divided into several classifications, like so:
Total: 7bn
Classification 1: 3bn,
Classification 2: 1bn,
... ,
Classification N: 0,3M
N is such a big number that when I put in a graph, most of the classifications don't even show up in there, so my manager suggested that I took anything that represents less than 5% of the total 7bn and classified them as "Others" to put it all together in the visual.
Then I made a measure "% of total" like:
% of total =
divide(
sum(values),
sumx(
allselected(table),
values
)
)
And this actually works perfect, except...
I wanna make a measure (or calculated column) that returns something like:
new classification =
if(
[% of total] > 0.05,
"Others",
[classification]
)
just to classify for me in the graph
but then only one of the new classifications returns as the old one, the rest returns "Others", but I know there's more than one, according to [% of total].
Can you think of another way to make this work? Is this a dumb question?
Thanks in advance
Create 2 separate measure for [others] & [classification] and create your final measure as below-
new classification =
var is_greater = IF([% of total] > 0.05, 1, 0)
RETURN
SWITCH(
is_greater ,
1,[Others]",
[classification]
)
I have a spreadsheet where Column A is the year, and column B is the shirt color used. The shirt colors are repeated.
I want to find a way to generate a list of the colors that have not been used in the last 10 years. The problem I am running into is due to the fact that the colors repeat. I tried using
=unique(filter(B2:B, A2:A<today()-(365*10)))
but shirts that were used in the last 10 years are then still included.
try:
=ARRAYFORMULA(TEXTJOIN(", ", 1, UNIQUE(IF(NOT(REGEXMATCH(B:B,
TEXTJOIN("|", 1, UNIQUE(FILTER(B:B, A:A>=YEAR(TODAY())-10))))), B:B, ))))
for dates in column A use:
=ARRAYFORMULA(TEXTJOIN(", ", 1, UNIQUE(IF(NOT(REGEXMATCH(B:B,
TEXTJOIN("|", 1, UNIQUE(FILTER(B:B, YEAR(A:A)>=YEAR(TODAY())-10))))), B:B, ))))
I have a master sheet with values of what I would sell for. I want to create a formula or rules where I can subtract commission based on the value of the cell. I want to be able to edit from the table only so I don't have to mess around with hundreds of cells formulas when things change. I also don't want to just take commission by percentage. I know how to link the cells. I want a formula that will look in the table and say hey its between the two values so ill extract this amount of commission. I have attached a picture of an example of the rules table.
I've tried doing IF statements and ran into too many arguments issues.
I expect the formula to look in my table and take out the proper commission beside it.
=ARRAYFORMULA(Main!B2-VLOOKUP(Main!B2,
{REGEXEXTRACT(Comission!$A$3:$A$13, "\d+")*1, Comission!$B$3:$B$13}, 2))
you can do various things like:
=ARRAYFORMULA(IF(A9:A<>"", IF(COUNTIF(A9:A, A9:A)>1,
B9:B-(B9:B*IFERROR(VLOOKUP(B9:B,
{{REGEXEXTRACT(A3, "\d+")*1, -B3% };
{REGEXEXTRACT(A4, "\d+")*1, -B4%};
{REGEXEXTRACT(A5, "\d+")*1, -B5%};
{REGEXEXTRACT(A6, "\d+")*1, -B6%};
{400, 0}}, 2))),
B9:B-(B9:B*IFERROR(VLOOKUP(B9:B,
{{REGEXEXTRACT(C3, "\d+")*1, -D3% };
{REGEXEXTRACT(C4, "\d+")*1, -D4%};
{REGEXEXTRACT(C5, "\d+")*1, -D5%};
{REGEXEXTRACT(C6, "\d+")*1, -D6%};
{400, 0}}, 2)))), ))
assuming Ema is a reseller and Jane & Yuki are one-timers
alternatives: https://webapps.stackexchange.com/q/123729/186471
=ARRAYFORMULA(IF(A2:A<>"", IFERROR(VLOOKUP(A2:A, Main!A2:B, 2, 0))-
IFERROR(VLOOKUP(IFERROR(VLOOKUP(A2:A, Main!A2:B, 2, 0)),
{IFERROR(REGEXEXTRACT(Comission!A3:A, "\d+")*1), Comission!B3:B}, 2)), ))
I have two Pandas data frames representing an inventory of items. Both data frames have four columns:
df1
id, item, colour, year
1, car, red, 2015
2, truck,, 2016
3, house, blue,
4, car, blue,
5, truck, red, 2015
df2
id, item, colour, year
1, house, blue, 2015
2, truck,, 2015
3, car, blue,
4, house,,
5, car, red, 2015
I know that these inventories are likely to represent the same object, so I would like to relate both of these.
For instance,
df1[1] = df2[5] (3 identique variables)
df1[4] = df2[3] (2 identique variables)
df1[3] (house, blue,) is probably the same as df2[1] (house, blue, 2015).
I have 2 main issues: how to do it efficiently, and how to give a reliability to the link.
I've thought of creating a common field which would be a combination of all the columns [item, colour, year] and merge on this. I would get the two first matches above; but they don't have the same reliability. I wonder if there would be an easy way to 'score' this reliability (at the moment I'm thinking of doing two merges, depending on variable availability).
The I would create another common field, with only 2 variables (item, colour), and merge on this. That would give me the link: (house, blue,) and (house, blue, 2015). This would obviously be a weaker link.
Any idea how to do this without merging sequentially? My current plan is to merge with 3 attributes (when they are present), then 2 attributes (there are 3 permutations) on what is left and has at least 2 attributes, and then 1 only. I would give a reliability score to the link based on the number of attributes I used to merge.
df = pd.DataFrame(
(df1.values[:, None] == df2.values).sum(2),
df1.index, df2.index)
matches = df.mask(df.lt(2)).stack()
def f(df):
i, j = df.name
return pd.concat([df1.loc[i], df2.loc[i]], axis=1, keys=['df1', 'df2']).T
matches.groupby(level=[0, 1]).apply(f).stack().unstack([-2, -1])