I have data in a table where there are "Buys" and "Sells" alongside the Quantity. I want query so that if it equals a "SELL" i multiply the Quantity column to negative. so far i am just selecting the data and taking from a certain timeframe. Nothing complex.
Using the update functionality along with the where clause you can edit a column in a table using certain filters. In this case the filter is where side=SELL.
If you add a backtick to the table name in the update statement this will update the table in place.
q)tab:([]time:10:00 12:00 13:00 14:00;side:`BUY`SELL`BUY`SELL;qty:300 400 300 500)
q)tab
time side qty
--------------
10:00 BUY 300
12:00 SELL 400
13:00 BUY 300
14:00 SELL 500
q)update qty:neg qty from tab where side=`SELL
time side qty
---------------
10:00 BUY 300
12:00 SELL -400
13:00 BUY 300
14:00 SELL -500
Updating in place:
q)update qty:neg qty from `tab where side=`SELL
`tab
q)tab
time side qty
---------------
10:00 BUY 300
12:00 SELL -400
13:00 BUY 300
14:00 SELL -500
Related
i have a table with detail transaction for lot. Lot are harvest and store before being ship.
Date lot transaction qty
5 sept 3 store 300
8 sept 3 ship -50
10 oct 3 ship -20
15 nov 3 ship -20
...
If i want the inventory for a specific moment, i simply sum between to date
I would like a query that can give me a sum from store to a specific month throught the entirr year like:
Lot sept to oct to nov ...
3 250 230 210 ...
Select lot, sum(qty) from ... where (date > 1 sept and date < 1 oct) as sept, (date > 1 sept and date < 1 nov)... group by lot
I did'nt find anything or figure out how to do it i a simple query.
Regards
Obtain one table with a query where is see the evolution of quantity over the year.
I have a dataset ab the donor of the organization. Each row starts with donor's ID and name, home address, donate_date_1, donate_amount_1, donate_date_2, donate_amount_2, keep going until 98. It looks similar to this
Donor_ID NAME donate_date_1 donate_amount_1 donate_date_2 donate_amount_2 Total_Amount
0 A Month/Day/Year 100 Month/Day/Year 200 300
1 B Month/Day/Year 200 Month/Day/Year 50 250
2 C Month/Day/Year 1000 Month/Day/Year 500 1500
The dataset has the donors' records from 1982. Every donor starts to donate on different date, ex: 2007 to donor1 is the first donation, but to donor 2 might be the 10th donation.
So here is my question: How can I combine all the dates to see which year the donors donate the most money and create the filter to see how much money was donated in total in the specific period?
I'm trying to find a way to obtain the amount of sales made from month to month but only comparing the aggregate total up to the current month's date.
In other words, I want to compare this month's sales up until now, against other months sales up until that month's same day.
Example using today's date as a reference (2016-06-18):
Total sales on January 2016 (*From 2016-01-01 to 2016-01-31*): 1000
Total sales on January 2016 (*From 2016-01-01 to 2016-01-17*): 650
Total sales on February 2016 (*From 2016-02-01 to 2016-01-17*): 670
Total sales on July 2016 (*From 2016-06-01 to current_date - 1*): 680
The structure of my data is as follows:
date sales
2016-01-01 5
2016-01-02 4
2016-01-03 5
2016-01-04 7
.
.
.
When I run the query I would like to have a monthly comparison of the totals mentioned above, so a result that looks like this:
month sales
2016-01 650
2016-02 670
.
.
2016-06 680
So comparing the month-to-date total of each month.
This is what I have tried so far and it seems to be fine, but somehow I always get a small difference whenever I make tests for limit days like the first of each month or the last.
select
order_month,
sum(sales) as sales
from table
where extract (day from order_date::date)
<=
extract (day from current_date::date)
- case when extract (day from current_date::date)=1 then 0 else 1 end
group by 1;
I'm new to Tableau. I have a customer-event table to show which customers attended which events (like webinars, etc). One of fields is sales - which is the sales for that customer 30 days from the date of the event.
custid eventid eventdt 30daysales
1 aa jan 1 $100
1 ab jan 1 $100
2 aa jan 2 $150
Note that customer 1 attended 2 events on the same day. So the sales number is duplicated. If I were building a report for a single event, it's no problem. But when I build a monthly report, I want sum(Sales) = $250 and not $350.
My report sample:
Month eventcount customercount 30daysales
Jan 2 2 $250
With tableau 9, I read that using an LOD formula would allow me to sum sales on a per customer basis. But I'm on Tableau 8.3 and I'm wondering what the manual workaround is.
How do I write the calculated field to compute the 30daysales without duplicating?
How to find group wise total(Sum) in SAP crystal report?
Dear All,
I have to find the Sum of value based on the Date(01/01/2014……) And Regional (North,West,East,Central) wise….But 2014,2013 column data type varchar(25)
Here I will give little Example of what I want to do:
Date Regional StationName 2014 2013
01/01/14 North AAA 1000.00 100.20
01/01/14 North BBB 500.00 50.00
1500.00 150.2
01/01/14 West ZZZ 100.00 00.00
01/01/14 West YYY 500.00 10.00
600.00 10.00
Grand Total :2100.00 160.2
to get that done you will have to create 2 groups, one by Date(suppressed) and another by Regional where you are going to place all of your fields. Then crate to formulas, one for 2014 and another for 2013 columns to convert those strings to number using tonumber() function. For example tonumber(2014). Then you will have to summarize 2014 and 2013 based on Regional Group and grand totals for both as well.