In Angular I have this simple model:
$scope.rdata = [
{1: 7, 2: 23,3: 9, 4: 13,5: 32},
{1: 23, 2: 8,3: 67, 4: 11,5: 6},
{1: 35, 2: 12,3: 24, 4: 17,5: 24},
];
I render it in html using ng-repeat:
<table>
<thead>
<p>Example of xy data rendered</p>
</thead>
<tbody>
<tr ng-repeat="row in rdata">
<td ng-repeat="c in col">
<div>{{row[c]}}</div>
</td>
<td>
<input type="range" id="example" min="0" max="1" step="0.01">
</td>
<td><div>
Value compiled: {result of input range value * value in row[c]}
</div></td>
</tr>
</tbody>
</table>
Basically I would like to bind the Value displayed in the last div of my last (where Value compiled is written) as the product of the input range value in the same row and the value in the last column of the same row.
If possible, I would like to understand if there is a way to reference whatever value located in column x and row y and be able to interact with it, put it in a formula etc... without building another angular model.
Let me know if it is sufficiently clear what I'm trying to achieve.
Edit:
my data is a bit more like this:
$scope.financials2 = [ { '2011': 98, '2012': 97, '2013': 100, name: 'Sales' },
{ '2011': -5, '2012': -6, '2013': -7, name: 'Costs of Goods Sold' },
{ '2011': 93, '2012': 91, '2013': 93, name: 'Gross Profit' },
{ '2011': -37, '2012': -36, '2013': -35, name: 'Operating Expenses' },
{ '2011': 54, '2012': 55, '2013': 58, name: 'Operating income' } ]
I may need to restructure the format of the data. The idea is by row I show concepts like Sales, Gross Profit etc... and Values are displayed in columns grouped by years
So the intermediate stage would be like:
Concept 2011 2012 2013
Sales 98 97 100
Cost of Goods Sold -5 -6 -7
Gross Profit 93 91 93
The idea is I would like to add two columns,
one with a slider (input range) for every row, which show growth
rates, so basically an input range going from -0.05 to +0.05
another column showing 2014 forecasts: so Sales 2014 = Sales 2013 * (1+ slider value), Gross Profit 2014 = Gross Profit 2013 * (1+ Slider value)
So we have 2 additional columns, with the first one containing sliders for every row and the second columns showing the result of the 2013 columns times the slider values.
Hope it's clearer now.
There are two pieces it seems you are trying to get here. The first is how do you get the value in the input field, and the second how do you get row[c].
For the input field, you can append the value of the input into your row using ng-model.
For your object it is best to define names for each value, rather than just {1:1, 2:3, 3: 4}, otherwise, just use an array. In the example provided, I called your last item in the object last in this jsfiddle example.
http://jsfiddle.net/reszjcu2/ - warning, the formatting is pretty crap.
Note, I had to provide key and value for the row object, as ng-repeat only works with arrays, not objects. Another reason to use an array if you aren't going to actually have named items in your object.
Related
I have a list of employees and want to generate an "Employee ID" based on the Hire Date value. I was hoping to be able to check the Hire Date value and compare it to an array of all the hire dates and to return the correct number.
You can see a list of these dates here: https://docs.google.com/spreadsheets/d/1ogjWzFPWLUECIP9YXL-r7RHM-hPWTPZ-6wX0sTV0QNc/edit?usp=sharing
Ideally, (using a small sampling of the dates above) it would look like the following:
Hire Date Employee ID
3/6/2012 1
3/30/2015 4
8/10/2015 5
8/10/2015 6
9/18/2015 7
9/18/2015 8
6/26/2020 9
3/6/2012 2
2/7/2013 3
use in B1:
={"ID"; ARRAYFORMULA(IFNA(VLOOKUP(A2:A, {SORT(A2:A), ROW(A2:A)-1}, 2, 0)))}
or:
=ARRAYFORMULA(RANK(A2:A, A2:A, 1))
if you want it to not repeat on the same date use:
={"ID"; ARRAYFORMULA(IF(A2:A="",,IFNA(VLOOKUP(A2:A&"z"&
COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A)), {SORT({A2:A&"z"&
COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A))}), ROW(A2:A)-1}, 2, 0))))}
I am working on an excel document that will, in then end, have over 90 checkboxes. The user will be able to select any or all of the 90, which will in turn use only those values in a simple If...then function to Print the findings in an output document.
Originally my code used For i = 1 to 8, then I manually coded in the values that the checkboxes will now hold. i.e.
Dim Sec(1 to 8) as string
For i = 1 to 8
Sec(1) = "5001"
Sec(2) = "5002"
And so on until the values I needed were added. This wasn't too difficult, I was simply tailoring the document to whatever department needed it. However, as with all things that start small, I've been tasked with creating a document site wide that will encompass all the values that can be selected ad-hoc. It's here that I find myself lost.
I'm currently looking at using
For Each ctl in Sheets("Sheet1").Controls
If Typename(ctl) = "Checkbox" then
If ctl.value = True then
To cycle through all of the checkboxes and find the ones that are checked, but how would I take the value of checkbox one (lets say is 5001) and make that sec(#) to fall in line with the rest of my code?
Is this a dynamic array situation, or would I be better off simply sending the values to a column somewhere on the worksheet, then creating a Array from the range of cells not blank?
A larger segment of code, so you can get the jist of where everything falls is here. Please disregard the Attachmate stuff, I'm pulling information with Getstring into a separate document if certain conditions are met.
Dim Sec(1 To 8) As String
Sec(1) = "6601"
Sec(2) = "6602"
For i = 1 To 2
Sess0.Screen.Moveto 16, 19
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("W")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.Moveto 18, 28
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Sec(i))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.Moveto 17, 29
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("19044")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.Moveto 19, 60
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("P")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<enter>")
Do
'If.....then....else...
loop until errorcode = "End"
Next i
Any help would be greatly appreciated. I'm definitely trying to learn, but I seem to have come to a wall in my knowledge and I'm not quite sure where else to look.
I have a table with the following columns:
Sales | Name | Est.close Date
I'm able to display all dates on one table,
I have created 4 tables , for est. close date next month, 3 , 6, 12 months, what I'm trying to do is display dates that are within 1, 3, 6 and 12 months of today.
I have tried ;
=DateAdd(DateInterval.Month, 6, Parameters!estimateclosedate.Value)
And
=DateAdd(DateInterval.Day, -1 * DatePart(DateInterval.WeekDay,Today()) + 6, Today())
Any help , would be greatly appreciated.Thanks
UPDATE:
I have 2 dates Today() and Fields!estimatedclosedate.Value.
What I'm trying to do is return estimatedclosedates that are within 1,3,6 and 12 months from today.
UPDATE 2:
I have tried
=Fields!estimatedclosedate.Value <> DATEADD(DateInterval.Month,1,Today())
but, this turns a boolean , TRUE.
If you want to show data in different tablixes you should set filter on each tablix.
For example:
In Value for each filter you should set such expressions:
=dateadd(DateInterval.Month, 1, DateTime.Today)
=dateadd(DateInterval.Month, 3, DateTime.Today)
=dateadd(DateInterval.Month, 6, DateTime.Today)
=dateadd(DateInterval.Month, 12, DateTime.Today)
EDIT (after comments)
Try to use this expression in exression field:
=CDate(Fields!estimatedclosedate.Value)
It will solve the problem with date format when convert DateTime to String.
I have a large dataset, x, consisting of 16201 x 49 cells, the first row contains labels e.g.:
'Entry1label' 'Entry2label', 'Entry3label', 'Entry4label'
'stimuli 1' 'stimuli 2' 0.1 10
'stimuli 1' 'stimuli 3' 0.1 10
'stimuli 2' 'stimuli 1' 0.1 40
Column 4 consist of cells with values of either 10, 20, 40 or 60. All of the columns have repeated entries (but different combinations across the columns). I want to filter the cell array for all entries in, e.g. 'Entry4label', that equal e.g. 10.
I've tried:
x([x{2:end, 4}] == 10, :)
This almost works, however, about every twenty cells there's a cell with value 40 left in! Similarly, if I try with 20, I get spurious occurrences of 10. If I use 40, I get spurious occurrences of 20, and finally for 60 I get some (but very few), 40s.
Any idea as to what is going on?
Code
out = x(find(cell2mat(x(2:end,4))==10)+1,:)
Output
out =
'stimuli 1' 'stimuli 2' [0.1] [10]
'stimuli 1' 'stimuli 3' [0.1] [10]
The problem was that the first element is a string for the fourth column.
Here: x([x{2:end, 4}] == 10, :)
Because you're finding the locations within a subset of the column, it's actually taking the row offset by one. I guess that your values in that column are mostly in blocks with an occasional change, so it makes it look as if it's matching most of them.
You can put the offset back:
x(find([x{2:end, 4}]==40)+1,:)
I am writing a perl script and am getting the values after many operations as follows:
'John', 10, .20
'John', 20, .05
'Paul', 50, .10
'Joe', 70, .03
'Joe', 12, .30
Now, I need to do the following operations:
Sum up the value of column 2 grouped by column 1.
Multiply column 2 by column 3 and find the sum of those answers again grouped by Column 1.
I am trying to see if this can only be accomplished by converting this array into a hash based on the first column or if there is a better way to do this.
Please note that this is not a homework exercise. I have tried to simplify the data by giving masking the original values. The values are of the type given above.
Expected Output:
'John', 30, 0.1
'Paul', 50, 0.1
'Joe', 82, 0.06
Figured out the answer while trying to "clean" it for posting here:
My code that works:
while (<FILE>)
{
chomp($_);
my ($name, $count, $percent) = split("\t");
$hash{$name}{"count"} += $count;
if ($count != 0)
{
$sonar_out_hash{$name}{"value"} += $percent * $count / 100;
}
}
Thanks to #KrishnachandraSharma for insisting that I post.