A bit of background first:
I am creating a web app that will display multiple reports onscreen simultaneously in a table. The way the reports are stored are in their own separate tables. As of now the angular app loops through the loaded reports and places them like so:
Group 1
Report1 Val1 Val2 Val3...
Report2 Val1 Val2 Val3...
ReportN Val1 Val2 Val3...
Group 2
Report1 Val1 Val2 Val3...
Report2 Val1 Val2 Val3...
ReportN Val1 Val2 Val3...
Group N
Report1 Val1 Val2 Val3...
Report2 Val1 Val2 Val3...
ReportN Val1 Val2 Val3...
The problem I am getting is that some of the reports will lack a row for a given grouping, which makes the overall table mismatched in the end. What I am wondering is if there is a means within ngRepeat to more or less skip a row while looping in order to only place the values in their respective group?
The only solution I can think of for this is to just manually insert blank rows in the other reports so that they will always have matching dimensions, but if angular can help facilitate this it would be better, and thus far Google has yielded no results.
For reference, this is my current table generating code:
<tbody>
<tr ng-repeat-start="row in loadedReports[0].data" ng-if="loadedReports.length > 1 && !loadedReports[1].empty">
<td ng-repeat="count in row track by $index" class="title" ng-show="$index > 12 - range || $first"><span ng-show="$first">{{ row[0] }}</span></td>
</tr>
<tr ng-repeat="report in $parent.loadedReports" ng-repeat-end>
<td ng-repeat="value in report.data[$parent.$index] track by $index" ng-class="{'title': $first && $parent.$parent.$last && ($parent.$parent.loadedReports.length === 1 || $parent.$parent.loadedReports[1].empty)}" ng-show="$index > 12 - range || $first">
<span ng-if="$parent.$parent.loadedReports.length > 1 && !$parent.$parent.loadedReports[1].empty && $first">{{ report.name }}</span>
<span ng-if="($parent.$parent.loadedReports.length === 1 && $first) || ($parent.$parent.loadedReports[1].empty) || $index > 12 - range">{{ value | numberFormat : report.dataType }}</span>
</td>
</tr>
</tbody>
Edit for clarification of code:
range is simply a control on screen that will allow up to 13 of the stored values in a row to be displayed, minimally 2.
data is a 2 dimensional array that contains a row for each group in the data set
Related
So, I am sure it's got to be simple, but, I cannot get Google Data Studio to provide an average of two aggregated columns. Example:
+----------+----------+
| Column 1 | Column 2 |
+----------+----------+
| A | TRUE |
| A | FALSE |
| B | TRUE |
| C | FALSE |
| A | TRUE |
| C | TRUE |
| B | FALSE |
| B | TRUE |
+----------+----------+
How can you get a count of the total value of A in Column 1 and divide it by the total number of TRUE in Column 2? I have tried Count(Column 1)/Count (Column 2) but it gives me the totals for the other values as well.
I have tried creating a new field with a CASE statement, but there is an error when trying to divide the two resulting CASE WHEN values:
CASE
WHEN Column 1 = A THEN 1
ELSE 0
END
The below shows two approaches of achieving the required calculation:
Approach 1: Ratio Metrics
Using Scorecards, Filters and Ratio Metrics:
1) Column 1 (A) Scorecard
- Add a Scorecard;
- Drag and Drop the field Column 1 onto the Metric field and change the aggregation to COUNT;
- Create and apply the Filter: Include Column 1 RegExp Match A
2) Column 2 (TRUE) Scorecard
- Add a Scorecard;
- Drag and Drop the field Column 2 onto the Metric field and change the aggregation to COUNT;
- Create and apply the Filter: Include Column 2 RegExp Match TRUE
3) Ratio Metric
- Select both Scorecards: Click on the Column 1 (A) Scorecard and then Ctrl + Click on the Column 2 (TRUE) Scorecard Scorecard;
- Blend Data: Right click on one of the selected Scorecards and select Blend data from the Drop-down.
Google Data Studio Report to demonstrate, as well as a GIF showing the process:
Approach 2: CASE Statements
An approach with CASE statements (create formula #1 and #2 at the Data Source-level; formula 3 can be created at the Data Source-level or Chart-level if required):
1) Column 1 (A)
CASE
WHEN REGEXP_MATCH(Column 1, "A") THEN "A"
ELSE NULL
END
2) Column 2 (TRUE)
CASE
WHEN REGEXP_MATCH(Column 2, "TRUE") THEN "TRUE"
ELSE NULL
END
3) Column 1 (A) / Column 2 (TRUE)
COUNT(Column 1 (A)) / COUNT(Column 2 (TRUE))
Added a New Page to the Google Data Studio Report to demonstrate as well as a GIF showing the process above:
I'm trying to produce a table with the sum of the values at the bottom.
Here HTML:
<table>
<tr ng-repeat="a in all |filter:'Gönderildi'" ng-init="$parent.yekun=yekun+a.total">
<td>{{a.total}}</td>
</tr>
<td>{{yekun}}</td>
</table>
Output:
10
10
23
101023
Instead of adding the numbers it is showing them side-by-side. I tried to sum. By the way column is in int form.
Instead of 2+4=4 it shows "24".
The type of a.total or yekun is string.
Check both of them are integers.
If any one of them is string, it will concatenate them.
I have this table that i will populate with random figures:
|--week--||-2016-||-2017-|
| 1 || 26734||6314916|
| 2 || 64565||9876768|
| 3 || 32243||9976757|
what I want to do is create a fourth column that is basically a variance of these numbers.
I created the script below which I know works as I had created it from for another table, there's no difference between these tables apart from the figures in them.
select CAST(ROUND(sum (([2017]) /(([2016]))-1)*100, 0) as NUMERIC(36,0)) as [variance%]
from table2
I get the below
|--week--||-2016-||-2017-| variance%
| 1 || 26734||6314916|0
| 2 || 64565||9876768|0
| 3 || 32243||9976757|0
why am i getting zeros when the other table i had delivers the actual results for variances?
All you need to do is mould your INT into float value. Something like this :
select
CAST(ROUND(sum (([2017]*1.0) /(([2016]))-1)*100, 0) as NUMERIC(36,0)) as [variance%]
read this stack exchange answer to know more about this.
Here is my sample List ,
$scope.list_element = [1,2,3,4,5,6,7,8,9,10];
I want to Iterate this List into Multiple Rows, each Row should contain 2 elements from the List.
required output,
1 , 2
3 , 4
5 , 6
7 , 8
9 , 10
i am getting like this,
1
2
3
4
5
6
7
8
9
10
I tried this using ng-repeat i.e: ng-repeat="val in list_element"
<div ng-repeat="val in list_element">
<p>{{val}}</p>
</div>
i know this is wrong.. it will give one by one... but i want to iterate 2 values in a row instead one...
The problem is the <p> tag will create a new line by default each time you execute it. And if you replaced it with anything else such as or just text inside a div
<div ng-repeat="val in list_element">
{{ val }}
</div>
this will output 12345678910
In order to solve it, you can use the special $odd or $even like this
<div ng-repeat="val in list_element tracked by $index">
<br ng-if="$odd"/>{{ val }}
</div>
notice that the <br/> will only add a new line to output when it's odd. Adjust it to get the result you are seeking.
Working in angularjs and looking to keep a running total based on a value retrieved from the data. The following code always returns the full total value for all items.
<div ng-repeat="child in pItem.childItems | orderBy:'displayOrder'" ng-init="$parent.totalValue = $parent.totalValue + child.field[0].value">
Changing that from the parent scope to the child clears the totalValue on each repeat. So the value always equals the child value just for that one item.
I'm looking for something which returns similar to the following. Where Item1 has a value 2, Item2 a value 3, and Item3 a value 4.
Item1 2
Item2 5
Item3 9
Try something like this, this should do the trick:
<div
ng-repeat="child in pItem.childItems | orderBy:'displayOrder'"
ng-init="child.totalValue = pItem.childItems[$index-1].totalValue + child.field[0].value">
{{child.field[0].value}} {{child.totalValue}}
</div>
So you basically sum with the previous totalValue result.