lookup value multiple comma separated from one cell - vlookup

In my excel sheet, Tab1 has this:
Col A Col B
Red     135
Green   231
Blue    776
Tab2 has this:
Col A Col B
Red,Green 366
Blue,Red 911
I would like to have the formula to auto calculate Col B value in Tab2. Any hint for that, thanks so much.

I assume the data are started at cell A1 for each tab.
Try this at column B of Tab2:
=SUMPRODUCT(--ISNUMBER(FIND('Tab1'!$A$1:$A$3,$A2))*1,'Tab1'!$B$1:$B$3)

Related

How to populate a cell with information stored in a location relative to the value in another cell?

Let's say I have
Sheet 1
A B C
1 # 20 30
2 # 75 90
3 # 46 21
Sheet 2
A B C
1 X Y
Where "X" is a dropdown list of Sheet 1's B column.
"Y" is where I want to fill in the value in the C column of the respective row of Sheet 1 for Sheet 2's column A selection.
How might I do this?
try:
=VLOOKUP(A1; 'Sheet 1'!B:C; 2; 0)
for arrayformula use:
=ARRAYFORMULA(IFNA(VLOOKUP(A1; 'Sheet 1'!B:C; 2; 0)))
In C1 try
=IF(LEN(A1), VLOOKUP(A1, Sheet1!B:C, 2, 0),)

PowerBI - concatenate column values ​in measure

i need concatenate column values (B) ​​in measure
Table1:
A B
1 RED
2 GREEN
3 BlUE
4 RED
5 BLACK
in measure = RED GREEN BLUE RED BLACK
How can i do this?
You can use CONCATENATEX() function.
Here is a simple example:
B values =
CONCATENATEX(
VALUES('Table'[B]),
'Table'[B],
" "
)
Result:

power bi: split column values by character and calculate sum

I have a table in which numeric values are there, but in some rows may contains values separated by comma. Since comma is in there so the data type of the column will be text.
I want to calculate sum of this column.
Here is my table-
Id Values
A 12
B 13
C 15
D 13,11,12
E 16
I want my sum to be - 12+13+15+13+11+12+16
Since the datatype of this column will be text so can the sum be calculated like I want or I have to do something like this-
Id Values
A 12
B 13
C 15
D 13
D 11
D 12
E 16
You can split the column by delimiter:
And split it into rows instead of columns:
The result will be as what you expected:
Then you can sum it as usual with DAX:
Sum = SUM(Data[Values])

Replace specific values in openpyxl

I have a excel file that looks like this:
1984 1 1
1985 1 1
I want to change all of the values in column 2 to 0 but I am not sure how to loop through rows.
I have tried:
import openpyxl
wb=openpyxl.load_workbook(r'C:\file.xlsx')
ws=wb['Sheet1']
for row in ws:
row = [x.replace('1', '0') for x in row]
but that must not be how you loop through rows.
my desired out put is:
1984 0 1
1985 0 1
You can do something like this:
import openpyxl
excelFile = openpyxl.load_workbook('file.xlsx')
sheet1 = excelFile.get_sheet_by_name('Sheet1')
currentRow = 1
for eachRow in sheet1.iter_rows():
sheet1.cell(row=currentRow, column=2).value = "0"
currentRow += 1
excelFile.save('file.xlsx')
Updates 2nd column to all zeros.

Merge multiple rows with same value into one row in pandas

I have seen that there are similar questions, but the answers did not quite fit my exact needs. I have a dataframe that contains rows with different values. Some of the rows however have exactly the same value.
Column1 Column2 Column3
0 a x x
1 a x x
2 a x x
3 d y y
4 d y y
What I would like to have is:
Column1 Column2 Column3
0 a x x
1 d y y
So basically I want to merge all rows with the same values in all columns into one row. What is the most decent way to do that in python?
Thank you in advance!
Call drop_duplicates:
In [214]:
df.drop_duplicates()
Out[214]:
Column1 Column2 Column3
0 a x x
3 d y y