How to create a Sparkline chart for for a particular name with values depending on the fields of other cells? - google-data-studio

I need help creating a sparkline chart for an example data as below:
name
timestamps
test
action
try 1
2022-11-16 22:39:35.653819+00:00
TRUE
TRUE
try 2
2022-11-16 22:39:33.171203+00:00
TRUE
TRUE
try 1
2022-11-16 22:39:30.699472+00:00
FALSE
TRUE
try 4
2022-11-16 22:39:27.711734+00:00
TRUE
FALSE
Let's say I am only trying to create a sparkline chart for try 1 against the timestamps.
What I want the chart to show is:
If test and action is TRUE and TRUE then for that timestamp Try 1 value is 2
If test and action is TRUE and FALSE then for that timestamp Try 1 value is 1
If test and action is FALSE and FALSE then for that timestamp Try 1 value is 0
I don't want to 'code' this into the google sheet as the data uploaded will be refreshed automatically and all my code will be gone when the data is refreshed.
Is there anyway I can code this into the sparkline chart itself on google data studio?
I tried creating a field in the metric section of the sparkline chart but it gives a system error.

hopefully this should get you started.
fix the timestamp to be studio-compatible
PARSE_DATETIME("%F %H:%M:%E*S",LEFT_TEXT(timestamps,26))
get the value score from test and action
CASE WHEN action='TRUE' THEN 1 ELSE 0 END+CASE WHEN test='TRUE' THEN 1 ELSE 0 END
you can use both these calculated fields as dimension and metric for spark chart.
lastly you can apply a filter to chart to see just the 'try 1' score.

Related

Google Data Studio bar chart comparing multiple metrics as % of the total

Let's say I have 10 companies that have signed up to my service, and then dropped off. I want to figure out how many of these companies are hitting milestones of usage in my system, so I want a bar chart that shows the data. For instance, I have 2 boolean fields on the companies, "Added Card Details" and "Logged in 3 times".
How do I create a bar chart which shows 2 bars, the % of companies which have that value set to "true", as the example below?
I'm pulling the data from BigQuery, but here's an example table of data to create the graph from:
Name
Added Card Details
Logged in 3 times
Com1
true
true
Com2
true
true
Com3
false
true
Com4
false
true
Com5
false
false
Com6
false
false
Com7
false
false
Com8
false
false
Com9
false
false
Com10
false
false
Should produce a graph which looks like:
Here's a sheet with example data and an example graph:
https://docs.google.com/spreadsheets/d/12jt1ZlhJ-5Hc8XtQsyXVVnLC1F6GOZz9euZkN2y1jNw/edit?usp=sharing
Here's my attempt at creating the graph. Not sure where to go from here when Dimension has to be declared and only allows one option.
https://datastudio.google.com/reporting/f9a2db1c-2c32-41b6-8e47-1848e2577417
One approach is to use a CONCAT field as the dimension and 2 calculated fields in each of the metrics:
Description
Details
Chart:
Column Chart
Dimension 1:Formula:
Actions"Actions"
Metric 1:Formula:Type:
Added Card DetailsCOUNT(IF(Added Card Details = "TRUE", Added Card Details, NULL)) / COUNT(Name)Number > Percent
Metric 2:Formula:Type:
Logged in 3 timesCOUNT(IF(Logged in 3 times = "TRUE", Logged in 3 times, NULL)) / COUNT(Name)Number > Percent
Publicly editable Google Data Studio report (embedded Google Sheets data source) and an image elaborate:

items show page doesn't render when a user is logged in on rails

I get the following in my terminal when I click on an item's show link in my rails app:
Started GET "/items/7-water-bottle" for 127.0.0.1 at 2017-10-17
13:00:36
-0700
Processing by ItemsController#show as HTML
Parameters: {"id"=>"7-water-bottle"}
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` =
2
ORDER BY `users`.`id` ASC LIMIT 1
Item Load (0.2ms) SELECT `items`.* FROM `items` WHERE `items`.`id` =
7 LIMIT 1
Review Load (0.2ms) SELECT `reviews`.* FROM `reviews` WHERE
`reviews`.`item_id` = 7
Rendering items/show.html.haml within layouts/application
Item Load (0.2ms) SELECT `items`.* FROM `items` WHERE `items`.`id` =
0 LIMIT 1
Rendered items/show.html.haml within layouts/application (6.4ms)
Record not found
Rendering public/404.html
Rendered public/404.html (0.5ms)
For some reason it's looking for an item with an id of 0. I don't have this issue when no one is logged in.
If you need more information, let me know.
Thanks!
It looks like the id that you are passing in is a string. Rails is trying to coerce that sting 7-water-bottle into an integer which will return zero (check in your console).
Are you by chance using the friendly_id gem? If so, you should use the Item.friendly.find(params[:id]) which will search by the slug you have defined instead of trying to search by the integer id.
If this is not the case please include more code and context so we can hunt this issue down!

Ag-grid show number of rows

I'm testing the enterprise version, and I want to know if I can show in the status bar row some custom text? (if status bar is not possible, is there an alternative?)
I want to show X rows / Y total rows of the table, or if that is not possible, just X rows
OR
Indicators: Blue - Manual Deposit, Red - Failed Deposit, Green - Success
(with custom style to show colors in this example)
Is this possible?
(BTW, I'm using Angular 1)
You asked 2 different questions, and I'll try to explain both.
I want to show X rows / Y total rows of the table
You have the Y total rows at gridOptions.api.getModel().getRowCount(). The X rows I assume refers to 'current displayed rows' and I think there's no current way of getting it. We used to though, so I may be wrong.
Indicators: Blue - Manual Deposit, Red - Failed Deposit, Green - Success
I guess you're talking about changing a cell/row style? For cell styling, have a look at Column Definition cellClassRules. From the webpage:
ag-Grid allows rules to be applied to include certain classes. If you use AngularJS, then this is similar to ng-class, where you specify classes as Javascript object keys, and rules as object values.
You can use it like so:
//'Success', 'Manual' and 'Failed' are placeholders for the actual values
// you must compare to.
cellClassRules: {
'green': function(params) { return params.value === 'Success'},
'blue': function(params) { return params.value === 'Manual'},
'red': function(params) { return params.value === 'Failed'}
},
For entire row styling, you can achieve it with what I explained in this other question
// Again, 'Success', 'Manual' and 'Failed' are placeholders
// for the actual values you must compare to.
gridOptions.api.getRowStyle(params) {
switch(params.data.myColumnToCheck){
case 'Success':
return {'background-color': 'green'};
case 'Manual':
return {'background-color': 'blue'};
case 'Fail':
return {'background-color': 'red'};
}
return null;
}
You can display current display row in ag grid by using below method
grid.api.inMemoryRowController.rowsToDisplay.length
Thanks

AmCharts Multipledatasets

I am stuck with http://www.amcharts.com/demos/multiple-data-sets/#theme-none, the creators of the graphic just put a random numbers to fill it, but I would like to load a CSV file which they have a plugin http://www.amcharts.com/demos/stock-
However, the second graphic is only for
"Stock" and financial purposses I would like to have the first one populated with a cvs file so I can compare more than 2 datasets.
Can someone help me? I will really appreciate it.
I need to read a little bit more, but I figured it out and Amcharts provides a lot of guide they are really nice and patience.
Below it's a pastie where you can find the whole solution.
this is a brief explanation:
{
title: 'Title',
fieldMappings: [ { // here you set the fields your chart will display
fromField: 'col1', // col1 because my csv has only 3 columns the first one contains the data
toField: 'value' // shows the value
}, {
fromField: 'col2', // this is the volume to display under the main graphic and that data is on column2
toField: 'volume' //
} ],
categoryField: "col0", // this is the category which it's display in this case i am using dates so it will display dates and my dates are in column 0 or column "A" in my csv file.
dataLoader: { / this is the plugin
url: "data/data2.csv", // the address
showCurtain: true, // widgets of the pluging
showErrors: true, // if there is an error loading amcharts will tell you
delimeter:"\t", // my csv is not delimited by "," but tabs.
format: "csv",
reverse:true // this is what sort of order you have your data, in my case from Z to A or major to minor.
}
here it't the code:
http://pastie.org/private/bwhvpnb6j8o1jv86cfsg

Checkboxes in LotusScript

I have a field of type checkbox which has many values. Is there a way to check which if a particular values is checked? Just like how we have "checked" method in Javascript, is there a similar method in LotusScript?
Checkboxes are just items in a document. To get the "checked" values you just read it from the document.
If your Checkbox- Field is called MyCheckbox then this code in a Button in the form would give you an array with all values:
Dim ws as New NotesUIWorkspace
Dim uidoc as NotesUIDocument
Dim doc as NotesDocument
Dim varValues as Variant
Set uidoc = ws.currentDocument
Set doc = uidoc.Document
varValues = doc.GetItemValue( "MyCheckBox" )
If not isnull( arraygetindex( varValues, "A" ) ) then
'do whatever you want if "A" is selected
Else
'do something else
End If
If not isnull( arraygetindex( varValues, "B" ) ) then
'do whatever you want if "B" is selected
End If
If not isnull( arraygetindex( varValues, "C" ) ) then
'do whatever you want if "C" is selected
End If
There's no checked property for a checkbox field in LotusScript API.
All Lotus Notes fields are text fields by its nature. Checkbox fields are text and multivalue fields.
Multivalue- means that field can hold several values at once.
If you do not use synonims in a checkbox field, then when you read this field contents, you will get a text-array, with all visible values selected.
I. e, if you have checkbox field with name myCheckBoxField with selected values:
apples
oranges
airplanes
then you can get this field value as:
....
Dim myCheckBoxFieldValues as Variant
myCheckBoxFieldValues = myDocument.getItemValue("myCheckBoxFieldValues")
and myCheckBoxFieldValues will be a string array, with values
apples
oranges
airplanes
But, if you have used synonims for your checkbox field, which is strongly recommended if there's a functionality that relates upon this checkbox field values, then the picture is a bit different.
Let say there is the following set of options for your checkbox field (synonims are separated via | symbol):
apples | 1
oranges| 2
plums | 3
tacos | 4
airplanes | 5
then, if you have selected options in your document:
apples
oranges
airplanes
and have read this field value as described above, you will get a string array with synonim values, not visible values.
I,e you will get an array with values:
1
2
5
Note that when you will work with values of checkbox fields.
And if you get a string array, with one empty element (index = 0), then your checkbox field does not have any option checked.

Resources