I have 2 SharePoint lists like below
I want to make a column in list B to count if this item listed or not in specific column in list A
list A
items
item1
item4
item6
list B
items Count in list A
item1 1
item2 0
item3 0
item4 1
item5 0
item6 1
item7 0
item8 0
How to do this ??
You could create a LOOK UP column in list B,and get information from list A,there is a count attribute of look up column that can be used.
Complete example for your referenceļ¼
https://wonderlaura.com/2013/08/06/sharepoint-column-count-related-items/
Updated:
Related
This is the available data:
Column A
Column B
Column C
Column D
Column E
item1
traitA
traitB
traitC
traitD
item2
traitE
traitF
traitG
traitH
item3
traitI
traitJ
traitK
item4
traitL
traitM
traitN
item5
traitO
traitP
I have a column of 5,000+ items. They all have different traits (some 2, some up to 20). Those traits are in the same row, in the columns next to the item. I already have the trait count per item and stacked the items for the right amount. Resulting in:
Column Q
Column R
item1
4
item2
4
item3
3
item4
3
item5
2
and:
Column Y
Column Z
item1
item1
item1
item1
item2
item2
item2
item2
item3
item3
item3
item4
item4
item4
item5
item5
The result I need is the following:
Column Y
Column Z
item1
traitA
item1
traitB
item1
traitC
item1
traitD
item2
traitE
item2
traitF
item2
traitG
item2
traitH
item3
traitI
item3
traitJ
item3
traitK
item4
traitL
item4
traitM
item4
traitN
item5
traitO
item5
traitP
I put this in cell Z2:
=VLOOKUP(Y2,$A:$E,2,FALSE)
This works but only for traitA, traitE, traitI, and so on (column B).
So what I need is a dynamic column index number. This needs to find how many 'item1' there are in Column Y in total, and then at which one out of the total in column Y it is at.
Also when you go to the next item, the column index number has to go back to '2', since that will make the VLOOKUP work.
The column index numbers need to be as follows:
Column Y
Column Z
item1
2
item1
3
item1
4
item1
5
item2
2
item2
3
item2
4
item2
5
item3
2
item3
3
item3
4
item4
2
item4
3
item4
4
item5
2
item5
3
Don't have too much experience with ROW and ROWS, I cannot get it to work. Maybe VBA offers the best solution. Or does there also needs to be a COUNTA function?
Any help would be truly appreciated. Thanks!
You can use this formula - based on a table called data
=LET(traits,data[[Column B]:[Column E]],
items,MAP(traits,LAMBDA(i,INDEX(data[Column A],ROW(i)-1))),
FILTER(HSTACK(TOCOL(items),TOCOL(traits)),TOCOL(traits)<>0))
The basic idea is to use TOCOL - for the traits that's easy.
Regarding the items the trick is to fill the traits-matrix with the according item - and then do the TOCOL
(Important: you have to be on the current channel of Excel 365 to have TOCOL and HSTACK)
In the table below each item has a 2-digit code. The first digit signifies a category.
I want to aggregate the items with the same first digit per person using Stata. Thus, the solution will be:
In this table, item1 = item11+item14+item15+item17 and item2=item21+item25 that are calculated per person.
clear
input str1 person item11 item21 item14 item15 item25 item17
a 2 3 5 1 3 50
end
egen item1 = rowtotal(item1*)
egen item2 = rowtotal(item2*)
drop item1? item2?
list
+------------------------+
| person item1 item2 |
|------------------------|
1. | a 58 6 |
+------------------------+
I'm trying to extract a text out of a column so I can move to another column using a pattern in python but I miss some results at the same time I need to keep the unextracted strings as they are>
My code is:
import pandas as pd
df = pd.DataFrame({
'col': ['item1 (30-10)', 'item2 (200-100)', 'item3 (100 FS)', 'item4 (100+)', 'item1 (1000-2000)' ]
})
pattern = r'(\d+(\,[0-9]+)?\-\d+(\,[a-zA-Z])?\d+)'
df['result'] = df['col'].str.extract(pattern)[0]
print(df)
My output is:
col result
0 item1 (30-10) 30-10
1 item2 (200-100) 200-100
2 item3 (100 FS) NaN
3 item4 (100+) NaN
4 item1 (1000-2000) 1000-2000
My output should be:
col result newcolumn
0 item1 (30-10)
1 item2 (200-100)
2 item3 (100 FS)
3 item4 (100+)
4 item1 (1000-2000)
You can use this:
df['newcolumn'] = df.col.str.extract(r'(\(.+\))')
df['result'] = df['col'].str.extract(r'(\w+)')
Output:
col newcolumn result
0 item1 (30-10) (30-10) item1
1 item2 (200-100) (200-100) item2
2 item3 (100 FS) (100 FS) item3
3 item4 (100+) (100+) item4
4 item1 (1000-2000) (1000-2000) item1
Explanation:
The first expression gets the content within parenthesis (including the parenthesis themselves). The second gets the first word.
You can also do this with .str.split in a single line:
df[['result', 'newcolumn']] = df['col'].str.split(' ', 1, expand=True)
Output:
col result newcolumn
0 item1 (30-10) item1 (30-10)
1 item2 (200-100) item2 (200-100)
2 item3 (100 FS) item3 (100 FS)
3 item4 (100+) item4 (100+)
4 item1 (1000-2000) item1 (1000-2000)
You must use expand=True if your strings have a non-uniform number of splits (see also How to split a dataframe string column into two columns?).
EDIT: If you want to 'drop' the old column, you can also overwrite it and rename it:
df[['col', 'newcolumn']] = df['col'].str.split(' ', 1, expand=True)
df = df.rename(columns={"col": "result"})
which exactly gives you the result you specified was intended:
result newcolumn
0 item1 (30-10)
1 item2 (200-100)
2 item3 (100 FS)
3 item4 (100+)
4 item1 (1000-2000)
You can extract the parts of interest by grouping them within one regular expression. The regex pattern now matches item\d as first group and anything inside the brackets with \(.*\) as the second one.
import pandas as pd
df = pd.DataFrame({
'col': ['item1 (30-10)', 'item2 (200-100)', 'item3 (100 FS)', 'item4 (100+)', 'item1 (1000-2000)' ]
})
pattern = "(item\d*)\s(\(.*\))"
df['items'] = df['col'].str.extract(pattern)[0]
df['result'] = df['col'].str.extract(pattern)[1]
print(df)
Output:
col items result
0 item1 (30-10) item1 (30-10)
1 item2 (200-100) item2 (200-100)
2 item3 (100 FS) item3 (100 FS)
3 item4 (100+) item4 (100+)
4 item1 (1000-2000) item1 (1000-2000)
I'm quite new to VBA and trying to combine multiple row records in a large data dump into a single row record with multiple headers.
The data is exported into an excel file from another program and takes the form of:
Order Item Qty
1 Item1 2
1 Item2 5
1 Item4 1
2 Item1 1
2 Item2 2
2 Item3 5
3 Item1 4
3 Item2 5
3 Item3 1
4 Item2 2
4 Item3 1
5 Item1 1
5 Item2 1
5 Item3 1
6 Item1 4
6 Item2 4
6 Item4 2
Which would then be sorted into:
Order Item1 Item2 Item3 Item4
1 1 4 1
2 1 2 5
3 4 5 1
4 2 1
5 1 1 1
6 4 4 2
I'm not expecting anyone to write my code but any pointers as to an overall approach would be much appreciated. Thanks!
I create helper column and formula to get the counting. Hope can help.
I am working on getting pricing based on the number of units we are ordering using Excel sumifs. The data I have looks something like this:
A B C D
Item1 Comp1 1 4.99
Item1 Comp1 10 3.99
Item1 Comp1 100 2.99
Item1 Comp2 1 13.99
Item1 Comp2 100 10.99
Item1 Comp3 1 2.99
Item1 Comp3 10 2.59
Item1 Comp3 50 2.19
Item1 Comp3 100 1.99
... ... ... ...
Where column A is the main item, column B is the individual components of the item in column A, and column C is the number we need to order in order to get the price listed in column D.
In a separate sheet, I have the following table:
A B C
Item1 10 FORMULA
Item2 5 FORMULA
Item3 20 FORMULA
... ... ...
The point of this sheet is to have the Item name as seen in Column A of the first table, column B holds the number we need to order, and column C (hopefully) lists the total price by adding all the components at their respective price breaks.
In this example, the sum for Item1 I am looking for is 3.99 + 13.99 + 2.59 = 20.57 because 10 items gets the 10 price break for component 1, the 1 price break for component 2, and the 10 price break for component 3.
So far I am able to sum the cost based on the item name in column C:
=SUMIFS(Table1[D], Table1[A], "="A2)
I am having trouble starting the second part which is basically only summing the maximum price break for each component where Table1[C] <= B2.