I have the following data set:
+--------+---------+----------+
| Date | Revenue | Expected |
+--------+---------+----------+
| Dez 5 | 51 | 1 |
| Dez 4 | 72 | 1 |
| Dez 3 | 72 | 1 |
| Dez 2 | 59 | 1 |
| Dez 1 | 81 | 1 |
| Nov 30 | 50 | 1 |
| Nov 29 | 53 | 1 |
| Nov 28 | 99 | 0 |
| Nov 27 | 85 | 0 |
| Nov 26 | 65 | 0 |
| Nov 25 | 94 | 0 |
+--------+---------+----------+
The column Expected determines whether or not the Revenue number has been confirmed. Now, I want to have a pivot table that sums up the revenues per month. The final result should be this:
+-------+-------------------+-----+
| Month | | |
+-------+-------------------+-----+
| Nov | Revenues | 446 |
| | Expected Revenues | 103 |
| Dez | Revenues | 335 |
| | Expected Revenues | 335 |
+-------+-------------------+-----+
I can't seem to get this working for the month November, because my calculated field looks like this:
=IF(Expected*1>0;Revenues*1;0)
I had to add *1 because it wouldn't work for some numbers, so you can mentally ignore this for the moment.
In any case, the result of this is the following:
+-------+-------------------+-----+
| Month | | |
+-------+-------------------+-----+
| Nov | Revenues | 446 |
| | Expected Revenues | 446 |
| Dez | Revenues | 335 |
| | Expected Revenues | 335 |
+-------+-------------------+-----+
Can anyone point me in the right direction here? I understand that the reason for this is most likely that the Expected column gets summed up first and then the IF comparison comes about. Is there a way to circumvent this?
Related
I'm trying to find the week of the year of particular dates using a formula in Excel. I found that Excel is considering the Sunday as the 1st day of the week instead of Monday as the first day.
I used the formula =WEEKNUM(A2) (where A2 is the date row) and got the result as below
--------------------------------
| Date | Week of Year |
--------------------------------
| 5/16/2015 | 20 |
| 5/17/2015 | 21 |
| 5/18/2015 | 21 |
| 5/19/2015 | 21 |
| 5/20/2015 | 21 |
| 5/21/2015 | 21 |
| 5/22/2015 | 21 |
| 5/23/2015 | 21 |
| 5/24/2015 | 22 |
| 5/25/2015 | 22 |
--------------------------------
But how do I get the result as below (Considering Monday as the first day of the week)
--------------------------------
| Date | Week of Year |
--------------------------------
| 5/16/2015 | 20 |
| 5/17/2015 | 20 |
| 5/18/2015 | 21 |
| 5/19/2015 | 21 |
| 5/20/2015 | 21 |
| 5/21/2015 | 21 |
| 5/22/2015 | 21 |
| 5/23/2015 | 21 |
| 5/24/2015 | 21 |
| 5/25/2015 | 22 |
--------------------------------
Pass a second argument to WEEKNUM: 2 stands for Monday.
=WEEKNUM(A2, 2)
I want to join 2 tables. I know I can do it with power query but as I am on Macbook I can't do it, unfortunately. Does anyone have any suggestions? (I would love to try this in VBA would that be possible?) I've created Pivot Tables before using VBA but never joining 2 tables. My goal is to create a Pivot Table from the resulting table (resulting table being after combining Table 1 and Table 2).
Table 1
Foreign Keys: Division and Location
Division | Year | Week | Location | SchedDept | PlanNetSales | ActNetSales | AreaCategory
----------|------|------|----------|-----------|--------------|-------------|--------------
5 | 2018 | 10 | 520 | 541 | 1943.2 | 2271.115 | Non-Comm
5 | 2018 | 10 | 520 | 608 | 4378.4 | 5117.255 | Non-Comm
5 | 2018 | 10 | 520 | 1059 | 1044.8 | 1221.11 | Comm
5 | 2018 | 10 | 520 | 1126 | 6308 | 7372.475 | Non-Comm
5 | 2018 | 10 | 520 | 1605 | 1119.2 | 1308.065 | Non-Comm
5 | 2018 | 10 | 520 | 151 | 2995.2 | 3500.64 | Non-Comm
5 | 2018 | 10 | 520 | 1637 | 6371.2 | 7446.34 | Non-Comm
5 | 2018 | 10 | 520 | 3081 | 1203.2 | 1406.24 | Non-Comm
5 | 2018 | 10 | 520 | 6645 | 7350.4 | 8590.78 | Vendor Paid
5 | 2018 | 10 | 520 | 452 | 1676.8 | 1959.76 | Non-Comm
5 | 2018 | 10 | 520 | 527 | 7392 | 8639.4 | Non-Comm
5 | 2018 | 10 | 520 | 542 | 6824.8 | 7976.485 | Non-Comm
5 | 2018 | 10 | 520 | 824 | 1872.8 | 2188.835 | Non-Comm
5 | 2018 | 10 | 520 | 1201 | 6397.6 | 7477.195 | Non-Comm
5 | 2018 | 10 | 520 | 1277 | 2517.6 | 2942.445 | Non-Comm
5 | 2018 | 10 | 520 | 1607 | 2196.8 | 2567.51 | Vendor Paid
5 | 2018 | 10 | 520 | 104 | 3276.8 | 3829.76 | Non-Comm
Table 2
Foreign Keys: Division and Location
Division | Location | LocationName | Region | RegionName | District | DistrictName
----------|----------|--------------|--------|------------|----------|--------------
5 | 520 | Location 520 | 1 | Region 1 | 1 | District 1
5 | 584 | Location 584 | 1 | Region 1 | 1 | District 1
5 | 492 | Location 492 | 1 | Region 1 | 2 | District 2
5 | 215 | Location 215 | 1 | Region 1 | 3 | District 3
5 | 649 | Location 649 | 1 | Region 1 | 4 | District 4
5 | 674 | Location 674 | 1 | Region 1 | 1 | District 1
5 | 139 | Location 139 | 1 | Region 1 | 1 | District 1
5 | 539 | Location 539 | 1 | Region 1 | 5 | District 5
5 | 489 | Location 489 | 1 | Region 1 | 5 | District 5
5 | 139 | Location 139 | 1 | Region 1 | 1 | District 1
5 | 161 | Location 161 | 1 | Region 1 | 6 | District 6
5 | 543 | Location 543 | 1 | Region 1 | 4 | District 4
5 | 166 | Location 166 | 1 | Region 1 | 6 | District 6
5 | 71 | Location 71 | 1 | Region 1 | 5 | District 5
5 | 618 | Location 618 | 1 | Region 1 | 5 | District 5
I did it with index match but it is super slow. Here's a screenshot.
I tried it with the above and then again with the Table Name and Column Names.
=INDEX(LocTable[[#Headers],[Region]], MATCH(MetricsTable[[#Headers],[Division]]&MetricsTable[[#Headers],[Location]],LocTable[[#Headers],[Division]]&LocTable[[#Headers],[Location]],0))
However the above creates a table array "multi-cell array formulas are not allowed in tables". Is the only solution to revert back to nontables so I can run my formula and just deal with the super slowness or is there an option in VBA etc? Thanks in advance!
I have this set of data in Excel:
Date | Year | Spend | Budget | Product
Jan | 2017 | 300 | 350 | Pencils
Feb | 2017 | 450 | 450 | Pencils
March | 2017 | 510 | 520 | Pencils
... | ... | ... |
Dec | 2017 | 234 | 240 | Pencils
Jan | 2018 | 222 | 222 | Pencils
Feb | 2018 | 458 | 500 | Pencils
March | 2018 | 345 | 400 | Pencils
... | ... | ... |
Dec | 2018 | 600 | 600 | Pencils
I'm trying to build a pivot table that shows:
RT stands for "running total"
Av stands for "available"
Year | 2017
| Jan | RT | Av | Feb | RT | Av | March | RT | Av
Pencils| 300 | 300| 50 | 450 | 750| 50| 510 |1260| 60
In brief, "available" = running total + budget for remaining months. Any ideas?
Thanks!
If I understand correctly:
available = sum(budget) - sum(spent)
running total = sum(spent)
You should add a column for running total, that will sum the spent column from the beginning up to current row.
And add a column for available, that will sum the budget column from the beginning up to current row, and will reduce the value of the "running total" column (of the same row) from it.
I have a following dataset in cassandra :
Table Structure
CREATE TABLE userlog (
term text,
ts timestamp,
year int,
month int,
day int,
hour int,
weekofyear int,
dayofyear int,
count counter,
PRIMARY KEY (term, ts, year,month,day,hour,weekofyear,dayofyear)
);
.
term | ts | year | month | day | hour | weekofyear | dayofyear | count
------------------+--------------------------+------+-------+-----+------+------------+-----------+-------
www.datastax.com | 2028-07-13 17:06:28+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www.datastax.com | 2015-07-28 16:17:36+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 6
www.datastax.com | 2015-07-28 16:17:36+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www.datastax.com | 2015-07-28 16:17:36+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www.datastax.com | 2015-07-28 16:21:15+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www.datastax.com | 2015-07-28 16:21:33+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www.datastax.com | 2015-07-28 16:21:50+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www.datastax.com | 2015-07-28 16:21:52+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www.datastax.com | 2015-07-28 16:21:53+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www | 2015-07-28 16:46:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:47:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:48:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:50:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:55:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
When I run this query :
SELECT * FROM userlog WHERE ts >= '2015-07-28 16:46' AND ts <= '2015-07-28 16:55' ALLOW FILTERING;
I get correct result :
term | ts | year | month | day | hour | weekofyear | dayofyear | count
------+--------------------------+------+-------+-----+------+------------+-----------+-------
www | 2015-07-28 16:46:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:47:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:48:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:50:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
www. | 2015-07-28 16:55:00+0530 | 2015 | 7 | 28 | 16 | 31 | 209 | 2
but when I try to delete the rows with the same conditions
DELETE FROM userlog WHERE ts >= '2015-07-28 16:46' AND ts <= '2015-07-28 16:55';
It throws following error :
InvalidRequest: code=2200 [Invalid query] message="Invalid operator >= for PRIMARY KEY part ts"
Am i missing something ? How to delete data in the specified time-range ? Also, is there any way to get the data in the specified time range (other than what I am doing?)
The DELETE command does not support range queries or the ALLOW FILTERING clause. From the documentation it only supports the = and IN operators:
You can delete an individual row by fully specifying both the partition and clustering columns.
You can delete a whole partition by just specifying the partition key.
And you can use the IN operator to do a few of these at once.
If you want to selectively delete rows from within a partition, you could first query for them using SELECT and then in your application issue a delete for each row returned from the SELECT.
Usually you wouldn't want to use ALLOW FILTERING on your SELECT statements since that is very inefficient, so normally you would specify the partition key when doing a range query SELECT. You would structure your schema so that the information you need for an operation is in known partitions so that you wouldn't need to do a full table scan to find things.
I have a set of data as below.
SHEET 1
+------+-------+
| JANUARY |
+------+-------+
+----+----------+------+-------+
| ID | NAME |COUNT | PRICE |
+----+----------+------+-------+
| 1 | ALFRED | 11 | 150 |
| 2 | ARIS | 22 | 120 |
| 3 | JOHN | 33 | 170 |
| 4 | CHRIS | 22 | 190 |
| 5 | JOE | 55 | 120 |
| 6 | ACE | 11 | 200 |
+----+----------+------+-------+
SHEET2
+----+----------+------+-------+
| ID | NAME |COUNT | PRICE |
+----+----------+------+-------+
| 1 | CHRIS | 13 | 123 |
| 2 | ACE | 26 | 165 |
| 3 | JOE | 39 | 178 |
| 4 | ALFRED | 21 | 198 |
| 5 | JOHN | 58 | 112 |
| 6 | ARIS | 11 | 200 |
+----+----------+------+-------+
The RESULT should look like this in sheet1 :
+------+-------++------+-------+
| JANUARY | FEBRUARY |
+------+-------++------+-------+
+----+----------+------+-------++-------+-------+
| ID | NAME |COUNT | PRICE || COUNT | PRICE |
+----+----------+------+-------++-------+-------+
| 1 | ALFRED | 11 | 150 || 21 | 198 |
| 2 | ARIS | 22 | 120 || 11 | 200 |
| 3 | JOHN | 33 | 170 || 58 | 112 |
| 4 | CHRIS | 22 | 190 || 13 | 123 |
| 5 | JOE | 55 | 120 || 39 | 178 |
| 6 | ACE | 11 | 200 || 26 | 165 |
+----+----------+------+-------++-------+-------+
I need formula in column name "FEBRUARY". this formula will find its match in sheet 2
Assuming the first Count value should go in cell E3 of Sheet1, the following formula would be the usual way of doing it:-
=INDEX(Sheet2!C:C,MATCH($B3,Sheet2!$B:$B,0))
Then the Price (in F3) would be given by
=INDEX(Sheet2!D:D,MATCH($B3,Sheet2!$B:$B,0))
I think this query will work fine for your requirement
SELECT `Sheet1$`.ID,`Sheet1$`.NAME, `Sheet1$`.COUNT AS 'Jan-COUNT',`Sheet1$`.PRICE AS 'Jan-PRICE', `Sheet2$`.COUNT AS 'Feb-COUNT',`Sheet2$`.PRICE AS 'Feb-PRICE'
FROM `C:\Users\Nagendra\Desktop\aaaaa.xlsx`.`Sheet1$` `Sheet1$`, `C:\Users\Nagendra\Desktop\aaaaa.xlsx`.`Sheet2$` `Sheet2$`
WHERE (`Sheet1$`.NAME=`Sheet2$`.NAME)
Provide Actual path insted of
C:\Users\Nagendra\Desktop\aaaaa.xlsx
First you need to know about how to make connection. So refer http://smallbusiness.chron.com/use-sql-statements-ms-excel-41193.html