Create pivot table from Google App Maker datasource - pivot-table

I have exported data from Google App Maker(2) into spreadsheet. The problem is, I have to do pivot table manually in the exported sheet in order to get the table such as in no(3). Image(1) show the field that I have in the datasource.
(1) Screenshot of what I have in my datasource
(2) Data exported from AppMaker into Spreadsheet
(3) Expected pivot table to be exported
Can anyone teach me how to query data from the existing datasource to produce another table such as in no(3) in Google App Maker directly, so that I just export that data directly to sheet and no need to do pivot manually after the data has been exported .. or is there anyway better than that anyone else know how to do it?

I would rather to go with some nice charts to layout these stats... but if you want to go Sheets way you'll need to do some scripting with Apps Script Sheets Advanced API.
// server side code
function addPivotTable_(spreadsheetId, pivotSourceDataSheetId, destinationSheetId) {
var requests = [{
// Request object goes here
}];
var response = Sheets.Spreadsheets.batchUpdate({'requests': requests}, spreadsheetId);
}

Related

How can I blend Google Sheets data with another data source?

I've connected Google Search Console as a data source and added a New Field called "Brand or Non-brand".
The "Brand or Non-brand" field take the Google Search Console "Query" dimension as a variable. The field uses a CASE statement to determine if the query includes a brand term like "Pepsi" or a non brand term like "Fizzy Drinks." This bit all works without error. See this example;
CASE
WHEN REGEXP_MATCH(Query, ".*pepsi.*") THEN "Brand"
ELSE "Non-brand"
END
I want to know if I can use a Google Sheet to store the various brand terms? The Google Sheet would be a new data source and would have a column called "brand terms." This would include things like Pepsi, Coke, Fanta, Dr Pepper.
I connected the data sources but I couldn't get the fields to appear in the other data source. For example "brand terms" wont appear in the CASE statement in the Search Console Data source. I experimented with blending the data, but was unsuccessful.
I guess it's going to look a bit like this;
CASE
WHEN REGEXP_MATCH(Query, GoogleSheet_BrandTerms) THEN "Brand"
ELSE "Non-brand"
END
Would anybody have any advice?

How to retrieve the rows from starting and ending index in firebase database

I am trying pagination feature in my project, I am using react with firebase.
My problem statement: if I have around 50 records in my database, what is the query if we want to select records 3 - 8?
If you want to use specific fields in front-end side then use slice and i think you can return your all list from backend and just slice from ui side.
let arr = [
{id:1,name:'One'},
{id:2,name:'Two'},
{id:3,name:'Three'},
{id:4,name:'Four'},
{id:5,name:'Five'},
{id:6,name:'Six'},
{id:7,name:'Seven'},
{id:8,name:'Eight'},
{id:9,name:'Nine'},
{id:10,name:'Ten'}
]
let selected = arr.slice(2,8);
console.log(selected)
Firebase Realtime Database doesn't have numeric index pagination. The API allows you to start at the beginning and page through the query results using startAt(), limitToFirst(), and other related methods, as described in the documentation.
If you absolutely must use indexes, you will have to read the entire set of results, populate an array, and pick out the desired results from that array using the indexes you want on the page.

How to use an array to work around google scripts "service invoked too many times for one day" error

I wrote a simple script to fetch the distance between two locations, each in a different cell in GoogleSheets (below). My sheet has one set of 65 locations in the top row and a second set of 6000 locations listed in the first column. I want to find the distance between each location in the top row and each location in the first column.
Given the size of my data set, I'm running into the "service invoked too many times for one day: route" error message. I found this post suggesting that one could create an array to execute calculations for the whole spreadsheet at once, rather than cell by cell. Would this be a suitable solution for my current problem? If so, how would I go about writing the script? Here's my current code:
function GOOGLEMAPS(start_address,end_address) {
Utilities.sleep(1000)
var mapObj = Maps.newDirectionFinder();
mapObj.setOrigin(start_address);
mapObj.setDestination(end_address);
var directions = mapObj.getDirections();
var meters = directions["routes"][0]["legs"][0]["distance"]["value"];
var distance = meters * 0.000621371
//Logger.log(distance)
return distance;
}
If you desire overcome a daily limit established by the Google Apps Script you should initialize a Map with the Google Maps Premium plan credentials. This means you should contact Google and purchase a Google Maps Platform Premium plan license in order to get additional quota allowances.
There is a Maps.setAuthentication(clientId, signingKey); method for this purpose.
Enables the use of an externally established Maps API for Business account, to leverage additional quota allowances. Your client ID and signing key can be obtained from the Google Enterprise Support Portal. Set these values to null to go back to using the default quota allowances.
source: https://developers.google.com/apps-script/reference/maps/maps#setAuthentication(String,String)
I hope this answer clarifies your doubt.

Getting data from Cognos TM1 via REST API

I'm working with IBM Cognos Tm1 REST API.
I need subset of the data values contained in a cube (Cube1 for example).
So, I'm executing a view (View1 for example) and obtain a cellset.
http://server:port/api/v1/Cubes('Cube1')/Views('View1')/tm1.execute?$expand=Cells($select=Ordinal,FormattedValue,Consolidated)
However, I obtain much more cell values than I need.
My questions are:
Can I create my own view via REST API only? (And how?)
Can I ask API to return only not consolidated values?
Can I obtain cell value in some other way, without views?
Try creating a view via ExecuteMDX
Post Query:
api/v1/ExecuteMDX?$expand=Axes($expand=Hierarchies($select=Name),Tuples($expand=Members($select=Name))),Cells($select=Ordinal,Value)
And then in the Body
{
"MDX": "SELECT
SELECT {[Version].[Actual]}*
{[Year].[2017]} *
{[Location]. [1001]}*
{[Period].[Total Year]} *
{[Currency].[USD]} *
[Department].[Total Department]} *
{[Product Type].[Total Product Type]} *
{TM1FILTERBYLEVEL({TM1SUBSETALL( [Account] )}, 0)}
{[Cube1 Measure].[Amount]} ON 0 FROM [Cube1]"
}
Good Luck!
You create dynamic views using TM1 Java APIs. You can find detailed documentation in \tm1_64\TM1JavaApiDocs\
or by default its
C:\Program Files\ibm\cognos\tm1_64\TM1JavaApiDocs
and sample codes are located in C:\Program Files\ibm\cognos\tm1_64\tm1api\samplecode\java
Hope this helps you.

Show encoded data from Redis

I have encoded data
"{\"brand\":\"newBrand\",\"Id\":\"1\",\"field\":\"1\",\"date\":1437487498449,\"period\":2,\"newUser\":0}"
which I publish with command: PUBLISH channel "{\"brand\":\"newBrand\",\"Id\":\"1\",\"field\":\"1\",\"date\":1437487498449,\"period\":2,\"newUser\":0}"
Then I retrieve these data (Node.js) and successfully show them on the frontend (Angular) in one line as a message.
I want to show them in table(UI grid) - (column1 - Id, column2 - brand etc.)
Is there a way to parse these data to show them separately (every piece of data in appropriate column) in the table?
In angular, to display data in a table you can use 'ng-repeat'.For details go through this URL:http://www.w3schools.com/angular/angular_tables.asp
Use JSON.parse then use ng-repeat
var parsedData = JSON.parse("{\"brand\":\"newBrand\",\"Id\":\"1\",\"field\":\"1\",\"date\":143748‌​7498449,\"period\":2,\"newUser\":0}")
http://www.w3schools.com/angular/tryit.asp?filename=try_ng_tables_simple

Resources