I have the following spreadsheet:
https://docs.google.com/spreadsheets/d/1Ib2Do3htfRg3NAuI-HyRA3MBM1XwUviFcAxlvF7q1J0/edit?usp=sharing
I have created 2 sparklines, 1 works, 1 doesn't. The one that does not work references the second column as the x-axis to calculate the slope. The slope is needed to give the graph some nice trending color.
My question is, how can I convert the second column into a serial [1, 2, 3, 4, 5]? So that when it is put as the x-axis, the slope would be calculated correctly. Of course, this conversion needs to happen within the formula itself. Thanks for any help.
try:
=ARRAYFORMULA(SPARKLINE(C2:C, {
"charttype", "line";
"color", IF(SLOPE(C2:C, ROW(B2:B)-1)>0, "lime", "red");
"linewidth", 2}))
I have a master sheet with values of what I would sell for. I want to create a formula or rules where I can subtract commission based on the value of the cell. I want to be able to edit from the table only so I don't have to mess around with hundreds of cells formulas when things change. I also don't want to just take commission by percentage. I know how to link the cells. I want a formula that will look in the table and say hey its between the two values so ill extract this amount of commission. I have attached a picture of an example of the rules table.
I've tried doing IF statements and ran into too many arguments issues.
I expect the formula to look in my table and take out the proper commission beside it.
=ARRAYFORMULA(Main!B2-VLOOKUP(Main!B2,
{REGEXEXTRACT(Comission!$A$3:$A$13, "\d+")*1, Comission!$B$3:$B$13}, 2))
you can do various things like:
=ARRAYFORMULA(IF(A9:A<>"", IF(COUNTIF(A9:A, A9:A)>1,
B9:B-(B9:B*IFERROR(VLOOKUP(B9:B,
{{REGEXEXTRACT(A3, "\d+")*1, -B3% };
{REGEXEXTRACT(A4, "\d+")*1, -B4%};
{REGEXEXTRACT(A5, "\d+")*1, -B5%};
{REGEXEXTRACT(A6, "\d+")*1, -B6%};
{400, 0}}, 2))),
B9:B-(B9:B*IFERROR(VLOOKUP(B9:B,
{{REGEXEXTRACT(C3, "\d+")*1, -D3% };
{REGEXEXTRACT(C4, "\d+")*1, -D4%};
{REGEXEXTRACT(C5, "\d+")*1, -D5%};
{REGEXEXTRACT(C6, "\d+")*1, -D6%};
{400, 0}}, 2)))), ))
assuming Ema is a reseller and Jane & Yuki are one-timers
alternatives: https://webapps.stackexchange.com/q/123729/186471
=ARRAYFORMULA(IF(A2:A<>"", IFERROR(VLOOKUP(A2:A, Main!A2:B, 2, 0))-
IFERROR(VLOOKUP(IFERROR(VLOOKUP(A2:A, Main!A2:B, 2, 0)),
{IFERROR(REGEXEXTRACT(Comission!A3:A, "\d+")*1), Comission!B3:B}, 2)), ))
Say that I have the dataset like this
1, 3, 2015-03-25 11-15-13
1, 4, 2015-03-26 11-16-14
1, 4, 2015-03-25 11-16-15
1, 5, 2015-03-27 11-17-11
...
I want to store the data by datetime
so I will have the following output folders
2015-03-25/
2015-03-26/
2015-03-27/
...
How to do that with pig?
Thank you
You can use MultiStorage for this.
Use a FOREACH GENERATE to create a column that contains the date part that you are interested and then something like
STORE X INTO '/my/home/output' USING MultiStorage('/my/home/output','2');
I have django model with DateField. I can get list of months of objects in such way:
months = [i.month for i in MyModel.objects.values_list('date', flat=True)]
and after delete duplicates I receive such list (example): [1, 2, 5, 6, 7, 9].
But if I have different years, I want to receive months in right date order. For example:
date1=31.08.2012, date2=31.12.2012, date3=05.05.2013.
So I want to receive not [5, 8, 12] but [8, 12, 5].
How can I do it?
You're trying to get the months in order of when they first appear chronologically?
list(set(date.month for date in MyModel.objects.order_by("date").values_list('date', flat=True)))
Sorting by year is the same as sorting by date. Yay!
The only way to do it would be to add the year in too:
dates = [(i.year, i.month) for i in MyModel.objects.values_list('date', flat=True)]
That would return this list (once duplicates are removed and sorted):
[(2012, 8), (2012, 12), (2013, 5)]
If you wanted later, you could then get just the months by:
>>> [x[1] for x in dates]
[8, 12, 5]
But note that there may well be duplicates in that list too (August In both 2012 and 2013 would come out as 8, for example), and you wouldn't necessarily know where the list changes from one year to the next.
I am trying to add two types of charts into one dashboard and filter them by country, like so:
the initial values shown should be for Europe, done via
'state': {'selectedValues': ['Europe']}
Chart 1 is a pie chart and should show the split between two variables within Europe and each country for let's say 2012, like so:
['Country', 'Speciality', 'Amount'],
['Europe', 'XYZ', 20441],
['Europe', 'ABC', 5355],
['Austria', 'XYZ', 477],
['Austria', 'ABC', 153],
['BeNeLux', 'XYZ', 1512],
['BeNeLux', 'ABC', 298],
['France', 'XYZ', 3080],
['France', 'ABC', 792],
and so on
Chart 2 should refer to the same two variables, but adding quarters, i.e. Q1, Q2, Q3 and Q4. Ideally I would like to have this as a 100% stacked column chart. Columns being Q1 Q2 Q3 Q4.
Question is: How do I add both charts into the dashboard and have the control filter both charts if I select for example France?
Thanks
Binding the filter to two charts is easy, as the documentation says:
// One-to-many binding where 'ageSelector' drives two charts.
dashboard.bind(agePicker, [ageVsSalaryScatterPlot, ageBarChart]);
This will mean that if you select 'Europe' it will change the filter for both charts. From your question it seems you may be a bit unclear on how to actually set this up (since your data isn't formatted correctly).
You will need 5 things:
DataTable containing information for all charts (so if you want quarter information, it needs to be in the DataTable as well
Dashboard object to contain the charts and controls
ChartWrapper object for the pie chart.
ChartWrapper object for the stacked column chart
ControlWrapper object for the selector
DataTable
Currently you have your data with only 3 columns:
['Country', 'Speciality', 'Amount'],
['Europe', 'XYZ', 20441],
['Europe', 'ABC', 5355],
['Austria', 'XYZ', 477],
['Austria', 'ABC', 153],
['BeNeLux', 'XYZ', 1512],
['BeNeLux', 'ABC', 298],
['France', 'XYZ', 3080],
['France', 'ABC', 792],
Since you also want quarters, you need to add that information as well.
['Country', 'Speciality', 'Amount', 'Q1', 'Q2', 'Q3', 'Q4'],
['Europe', 'XYZ', 20441, 1, 2, 3, 4],
['Europe', 'ABC', 5355, 1, 2, 3, 4],
['Austria', 'XYZ', 477, 1, 2, 3, 4],
['Austria', 'ABC', 153, 1, 2, 3, 4],
['BeNeLux', 'XYZ', 1512, 1, 2, 3, 4],
['BeNeLux', 'ABC', 298, 1, 2, 3, 4],
['France', 'XYZ', 3080, 1, 2, 3, 4],
['France', 'ABC', 792, 1, 2, 3, 4],
Dashboard Object
A dashboard object points to a <div> element that contains the other <div> elements for the charts and controls. So in your case, something like:
Then you create the dashboard using code like this:
var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard'));
ChartWrappers
So you have two charts, and you need to create two separate wrappers. A wrapper basically gives all the details on what that chart will need to be created:
Where on the page it goes (the <div>)
Where it will take its data from
What type of chart / options it will use
The piechart only uses columns 0, 1, 2, so you set the 'view' property of the object to limit the data to those columns.
Do the same with the stackedcolumnchart, using columns 0, 1, 3, 4, 5, 6.
Both charts need to take data from the same DataTable though, otherwise filtering one chart won't affect the other (the filter will apply to the DataTable, so if you have two of them, you can only change one at a time).
ControlWrapper
Like the ChartWrapper, you need to create a ControlWrapper object that has all the details about the Control you use.
Once you have all your objects set up, you can draw the dashboard and bind the control to the two charts with the code at the top of this answer.
References
If you're still confused, play around with Google Playground for Dashboards to get an idea of how it works.