Excel 2010 Macro to compare more then two columns for finding the matched value via macro or VBA - vba

I have two sheets (sheet1 and sheet 2) in sheet1 there is more than two columns I want to match or check the difference value; column name are Chq. No., Name and Amount in sheet1 and sheet2.
Sheet 1
Date Chq. No. Name Amount
9/22/2015 22 REETA 1,400.00
9/21/2015 30 SUMIRTA 1,400.00
8/18/2015 31 NIRDUL KUMARI 200.00
8/21/2015 56 JAGDAMBA MISHRA 200.00
8/21/2015 58 ARUN KUMARI 200.00
8/21/2015 59 SANTOSH KUMARI 200.00
Sheet2
9/22/2015 22 REETA 1,400.00
9/21/2015 30 SUMIRTA 1,400.00
8/18/2015 33 NIRDUL KUMARI 200.00
8/21/2015 55 JAGDAMBA MISHRA 200.00
8/21/2015 58 ARUN KUMARI 200.00
8/21/2015 60 SANTOSH KUMARI 200.00
My side I am sharing the example with I am facing in actual, kindly help me.

Nitin in your case Cheque no is best field to match both databases,, you can use this one
=IF(ISERROR(MATCH(Sheet1! $B2,Sheet2! $B$2:$B$10,0)),"No match in B","")
Or you can use either this,
=INDEX(Sheet1! $A$2:$C$6,MATCH(Sheet2! $A 2,Sheet1! $A$2:$C$6,0))

Related

Recreating SUMIFS in SQL with conditional logic

I'm having a difficult time writing the SQL I'm able to accomplish with Excel SUMIFS. The ultimate goal is create share of requirement (loyalty) metric for each Customer. In the below, I'm trying to create the Category_Sales column. All other columns I already have in my SQL.
Here is what my Excel SUMIFS looks like.
=(Brand_Sales (range) , Cust_ID (range), Cust_ID (row), First_Buy (range), >=Brand_Str (row), Last Buy (range) <=, Brand_End (row))
The 268 value for Innocent is attained from the sum of Innocent, Cresco, Supply, and PTS since their First_Buy & Last_Buys are all inside the range of the Innocent Brand Start & End.
State
Brand
Cust_ID
First_Buy
Last_Buy
Brand_Str
Brand_End
Brand_Sales
Category_Sales
IL
Innocent
xyz
4/9/2022
4/9/2022
4/7/2022
5/29/2022
64
268
IL
Cresco
xyz
4/15/2022
4/15/2022
1/1/2022
5/30/2022
57
446
IL
Supply
xyz
4/15/2022
4/15/2022
1/1/2022
5/30/2022
45
446
IL
Rythm
xyz
1/3/2022
1/13/2022
1/1/2022
5/30/2022
121
446
IL
Natures
xyz
1/22/2022
1/22/2022
1/1/2022
5/30/2022
57
446
IL
PTS
xyz
4/26/2022
4/26/2022
1/1/2022
5/30/2022
102
446

In Azure Data bricks I want to get start dates of every week with week numbers from datetime column

This is a sample Data Frame
Date Items_Sold
12/29/2019 10
12/30/2019 20
12/31/2019 30
1/1/2020 40
1/2/2020 50
1/3/2020 60
1/4/2020 35
1/5/2020 56
1/6/2020 34
1/7/2020 564
1/8/2020 6
1/9/2020 45
1/10/2020 56
1/11/2020 45
1/12/2020 37
1/13/2020 36
1/14/2020 479
1/15/2020 47
1/16/2020 47
1/17/2020 578
1/18/2020 478
1/19/2020 3578
1/20/2020 67
1/21/2020 578
1/22/2020 478
1/23/2020 4567
1/24/2020 7889
1/25/2020 8999
1/26/2020 99
1/27/2020 66
1/28/2020 678
1/29/2020 889
1/30/2020 990
1/31/2020 58585
2/1/2020 585
2/2/2020 555
2/3/2020 56
2/4/2020 66
2/5/2020 66
2/6/2020 6634
2/7/2020 588
2/8/2020 2588
2/9/2020 255
I am running this query
%sql
use my_items_table;
select weekofyear(Date), count(items_sold) as Sum
from my_items_table
where year(Date)=2020
group by weekofyear(Date)
order by weekofyear(Date)
I am getting this output. (IMP: I have added random values in Sum)
Week Sum
1 | 300091
2 | 312756
3 | 309363
4 | 307312
5 | 310985
6 | 296889
7 | 315611
But I want in which with week number one column should hold a start date of each week. Like this
Start_Date Week Sum
12/29/2019 1 300091
1/5/2020 2 312756
1/12/2020 3 309363
1/19/2020 4 307312
1/26/2020 5 310985
2/2/2020 6 296889
2/9/2020 7 315611
I am running the query on Azure Data Bricks.
If you have data for all days, then just use min():
select min(date), weekofyear(Date), count(items_sold) as Sum
from my_items_table
where year(Date) = 2020
group by weekofyear(Date)
order by weekofyear(Date);
Note: The year() is the calendar year starting on Jan 1. You are not going to get dates from other years using this query. If that is an issue, I would suggest that you ask a new question asking how to get the first day for the first week of the year.

How to do conversion of units between two tables in SAP HANA Database

Hi I stumble upon some problem with SAP HANA database please note. I have some toy example problem. I tried to come up with solution, but I cannot figure out.
I have two tables one of Volume table
Row MATERIAL BASE_UOM PERIOD SUMMAND
1 55555 KG 201106 99
2 55555 KG 201204 16
3 55555 KG 201301 71
4 55555 KG 201411 83
5 55555 KG 201509 21
6 55555 PAL 201510 64
7 55555 PAL 201511 69
8 55555 KG 201512 55
9 55555 ZRS 201601 81
10 55555 KG 201602 3
11 55555 KG 201603 74
12 55555 KG 201604 58
13 55555 ZRS 201605 8
14 55555 KG 201606 22
The second table is Conversion Table
Row MATERIAL UNIT BASE_UOM UOMN1D UOMZ1D Conversion Rate
1 55555 KG KG 1 1 1
2 55555 CSE KG 1,000.00 2,016.00 2.016
3 55555 ST KG 1,000.00 56 0.056
4 55555 LAY KG 100 3,024.00 30.24
5 55555 PAL KG 100 54,432.00 544.32
6 55555 ZDK KG 59,778.00 54,432.00 0.910569106
7 55555 ZSE KG 59,778.00 54,432.00 0.910569106
8 55555 ZNO KG 59,778.00 54,432.00 0.910569106
9 55555 ZFI KG 59,778.00 54,432.00 0.910569106
10 55555 ZRV KG 1,000.00 57 0.057
11 55555 ZRS KG 1,000.00 2,052.00 2.052
Please bear in mind that Row column is indicative!
Key between tables is MATERIAL column.
I would like to convert all fields in column SUMMAND (Volume table), when there are not KG in BASE_UOM column Volume table e.g. in row 6 is PAL into KG or row 13 ZRS into KG. If we are in situation that we have KG we do not need to update column SUMMAND. To convert PAL into KG I need to look up at Conversion Table at MATERIAL and UNIT Column (look up PAL field) and get row 5 from Conversion Rate column (UOMZ1D/UOMN1D) 544.32*64 (64 is coming from Volume table row 6 Column SUMMAND) and so on. Finally, each individual MATERIAL has its own conversion rate.
The final output of Volume table should look like this. Row 6,7,9,13 is updated correctly.
Row MATERIAL BASE_UOM PERIOD SUMMAND
1 55555 KG 201106 99
2 55555 KG 201204 16
3 55555 KG 201301 71
4 55555 KG 201411 83
5 55555 KG 201509 21
6 55555 PAL 201510 34836.48
7 55555 PAL 201511 37558.08
8 55555 KG 201512 55
9 55555 ZRS 201601 166.212
10 55555 KG 201602 3
11 55555 KG 201603 74
12 55555 KG 201604 58
13 55555 ZRS 201605 16.416
14 55555 KG 201606 22
How I can check for every possible combination to convert all units into KG between this two tables. Would like to suggest me how to scale it, if I have longer list conversion between UNIT and BASE_UOM from Conversion Table imagine like 90 unique possible combinations. What SQL query I need to build in order to achieve the desired output. Any kind of solution are welcome.
Based on your description, you might want to use an inner join to match up the conversion factors to the material.
Something along the lines of this:
SELECT
v.MATERIAL
, v.BASE_UOM as ORIGINAL_UOM
, v.PERIOD
, c.UNIT as TARGET_OUM
, (c.UOMZ1D/c.UOMN1D) * v.SUMMAND as SUMMAND_TARGET_OUM
FROM
VOLUMES v
INNER JOIN CONVERSION c
ON (v.MATERIAL, v.BASE_UOM)
= (c.MATERIAL, c.UNIT)
This query relies on that there is one and only one matching entry in the conversion table for each possible material/base_uom combination.
If no match can be found, the corresponding record from VOLUMES will be omitted in the output.
It's obviously possible to design this more resilient to missing data (e.g. by fall-back output of unchanged data or transitive lookups), but the given solution is straight forward and easy to understand and debug.
Note, that this does not make use of SAP HANA's built-in unit-of-measure conversion functions. As these are designed to replicate the UOM conversion logic of SAP NetWeaver -based applications, these are probably not what you want in this case.

Excel 2007 Calculations

I have a Excel sheet, one date column with different description and values. How can I calculate the sum of the values for each dates using formula not pivot table?
I need summary as shown below:
Date Jun-15 Jul-15
1 175.00 200.00
2 100.00 75.00
3 200.00 175.00
4 60.00 70.00
5 20.00 225.00
6 80.00 50.00
You can use a simple SUMIF() formula:
Hi you can try this to solve your problem. Please let me know it this resolves your query.

How to read data on a specific row from excel by asking the name of that row?

I have the following excel file:
W1000x554 1032 408 52.1 29.5 70700 12300
W1000x539 1030 407 51.1 28.4 68700 12000
W1000x483 1020 404 46 25.4 61500 10700
W1000x443 1012 402 41.9 23.6 56400 9670
W1000x412 1008 402 40 21.1 52500 9100
W1000x371 1000 400 36.1 19 47300 8140
W1000x321 990 400 31 16.5 40900 6960
W1000x296 982 400 27.1 16.5 37800 6200
W1000x584 1056 314 64 36.1 74500 12500
I want to define a function that can ask the user for one of the first column's names and then read all the relevant data of that row later.
For example if the user defines W1000x412 then read : 1008 402 40 21.1 52500 9100.
Any ideas?
I suspect what #Marc means is that a formula such as in J2 below (copied across and down as necessary) will 'pick out' the values you want. It is not clear to me from your question whether these should be kept separate (as in Row2 of example) or strung together (CONCATENATE [&] as in J7 of example, where these are space [" "] delimited):
I am also not entirely sure about your 'define a function' but have assumed you do not require a UDF.
I have used Row1 to provide the offset for VLOOKUP, to save adjusting manually the formula for each column.
ColumnI is the expected user input, that might be best by selection from a Data Validation List with Source $A$2:$A$10.