Getting previous period/same period last year attribute filter - gooddata

I'm trying to enable drill-ins for measures which are specified as "previous period" or "same period last year" of another measure. When a drill event is fired, the intersection I get looks like this:
[
{
id: 'fkdljsfkdljfdkslj_pop',
title: 'Constituents',
header: {uri: '/gdc/md/projectid/obj/12345', identifier: 'ahdueom'}
},
{
id: '54321',
title: 'Oct/FY2018,
header: {uri: '/gdc/md/projectid/obj/6789', identifier: 'constituentdateadded.month.short'}
}
]
What I want to do is use this information to call getValidElements (/gdc/app/projects/projectid/executeAfm/debug) to get the items involved in this drill event using the first intersection element as a metric and the second as an attribute filter. However, if I want to get the items for the previous period or the same period last year I need a different attribute filter.
Is there any endpoint that I can call to get the attribute filter which corresponds to the same period last year (in this example 'Oct/FY2017') or the previous period ('Sep/FY2018')?

Maybe you could use relative date filter in AFM to simulate previous period. Documentation is here https://sdk.gooddata.com/gooddata-ui/docs/filter_visual_components.html#relative-filter-examples
If whis won't help you, could you please specify more your use case - what exactly you want to achieve?

Related

Report builder (SSRS) SWITCH statement blank values

For a report I'm building, there are fields that are dependent on a user selecting to add additional people to their policy (named in the dataset as dependent1, dependent2, etc).
We need to determine whether these dependants are adults or children for reporting. This will be done via DOB and a DateDiff which I understand
Currently, I can get the report to show ADULT or CHILD if data is present, however if there isn't any data I can't return a "" value, it just defaults to ADULT.
I'm using:
=Switch(DateDiff("yyyy", Fields!Dependant1DoB.Value, Fields!Policy_Start_Date.Value) < 18, "CHILD",
DateDiff("yyyy", Fields!Dependant1DoB.Value, Fields!Policy_Start_Date.Value) >= 18, "ADULT",
DateDiff("yyyy", Fields!Dependant1DoB.Value, Fields!Policy_Start_Date.Value), "")
I also created another column which uses the DateDiff between Fields!Dependant1DoB.Value & Fields!Policy_Start_Date.Value to show the number of years. This works and returns a number. however for some unknown reason where there's no data it still returns "2019" which may be effecting it? I've tried including this in the Switch statement (DateDiff("yyyy",Fields!Dependant1DoB.Value,Fields!Policy_Start_Date.Value)=2019, "")) but this still doesn't work.
Someone please help as this is driving me loopy!
You need to first check for nothing and then apply the switch function, example below:
=IIF(IsNothing(Fields!Dependent1DoB.Value),"",
Switch(
DateDiff("yyyy",Fields!Dependent1DoB.Value,Fields!Policy_Start_Date.Value)<18, "CHILD",
DateDiff("yyyy",Fields!Dependent1DoB.Value,Fields!Policy_Start_Date.Value)>=18, "ADULT"
)
)

Are Heart Points available in the REST API?

Are Heart Points available in the REST API for reading? IF so, how do we get to them? I'm not seeing the documentation data. Thanks.
Eric
You should use the Users.dataSources.datasets API endpoint. You can grab the hearts points merged from all data points by querying the dataSourceId "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes". It returns a JSON object with an array called "points". You'll find each heart point in that list and if you drill down further for each heart point you'll get the derived source.
The endpoint takes the form:
https://www.googleapis.com/fitness/v1/users/me/dataSources/dataSourceId/datasets/datasetId
Replace the following in the URL above:
dataSourceId: derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes
datasetId: The ID is formatted like: "startTime-endTime" where startTime and endTime are 64 bit integers.
Expanding on WiteCastle's answer, this datasource will provide you with the heart points.
"derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes"
You will need to specify a timeframe denoted by the datasetId parameter which is a start time and and an end time in epoch time with nanoseconds format, e.g.:
1607904000000000000-1608057778000000000
The json response includes an array of points, essentially each time the sensor detected the user's activity. The 'heart points' are accessible within each point's "fpVal". Example of a point is below:
{
"startTimeNanos": "1607970900000000000",
"endTimeNanos": "1607970960000000000",
"dataTypeName": "com.google.heart_minutes",
"originDataSourceId": "derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm",
"value": [
{
"fpVal": 2, <--- 2 heart points recorded during this activity
"mapVal": []
}
],
"modifiedTimeMillis": "1607976569329"
},
To get the heart points for today, specify the timeframe (00:00-23:59 in epcoch format), then loop through each point adding up all the "fpVal" values.

WooCommerce: How to automatically select variation attribute dropdown field when there is only 1 option?

So I feel like this isn't too complicated of a request, but I simply can't figure it out. On my WooCommerce site, I have some variable products. There are 3 dropdown variation attributes in the following order (top to bottom): Color, Type, and Part Number. Each variation has a unique part number (only 1 part number per combination), so there is literally no need for the user to select the part number after they have chosen color & type. However, I need that part number to display for purposes of my product feed and so the customer can see the part number they have chosen by the previous 2 options.
My question is; since selecting a "Color" and "Type" narrows the final field ("Part number") down to only 1 option, how do I instruct WooCommerce to automatically select the single "part number" option that's available?
You can do this with JS:
jQuery('a.toggle_component').click(function(e){
if(!(jQuery(e.target).parents('.component').find('select.component_options_select > option[selected=selected]').val())) {
jQuery(e.target).parents('.component').find('select.component_options_select > option:nth-child(2)').attr('selected','selected');
jQuery(e.target).parents('.component').find('select.component_options_select').change();
}
});

Podio API filtering by date range

I'm trying to filter tasks by date range and I'm getting errors whatever I try. This is how my request looks like: http://api.podio.com/task?completed=true&created_on%5Bfrom%5D=2016-06-23&created_on%5Bto%5D=2016-06-28&limit=100&offset=0&sort_by=rank&sort_desc=false&space=4671314
Here I'm trying to filter by created_on and I'm suplying {from: "2016-06-23", to: "2016-06-28"} but it's always returning the same error - invalid filter. I'm trying to filter tasks that are created in the last 5 days here.
The tasks API reference can be found in their API docs.
What am I doing wrong?
Date ranges can be separated by -.
To display "all my tasks created between 1st Jan 2014 and 1st Jan 2016" :-
/task?created_on=2014-01-01-2016-01-01&responsible=0'
Podio API get task filtering by date range use below :
/task/?created_on=2017-04-25-2017-05-01&offset=0&sort_by=rank&sort_desc=false&space=xxxxxxx

Is getting the General ID same as getting FormattedID in rally?

I am trying to get the ID under "General" from a feature item in rally. This is my query:
body = { "find" => {"_ProjectHierarchy" => projectID, "_TypeHierarchy" => "PortfolioItem/Feature"
},
"fields" => ["FormattedID","Name","State","Release","_ItemHierarchy","_TypeHierarchy","Tags"],
"hydrate" => ["_ItemHierarchy","_TypeHierarchy","Tags"],
"fetch"=>true
}
I am not able to get any value for FormattedID, I tried using "_UnformattedID" but it pulls up an entirely different value than the FormattedID. Any help would be appreciated.
LBAPI does not have FormattedID field. You are correct using _UnformattedID. It is the FormattedID without the prefix. For example, this query:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ProjectHierarchy":2222,"_TypeHierarchy":"PortfolioItem/Feature","State":"Developing",_ValidFrom: {$gte: "2013-06-01TZ",$lt: "2013-09-01TZ"}},sort:{_ValidFrom:-1}}&fields=["_UnformattedID","Name","State"]&hydrate=["State"]&compress=true&pagesize:200
shows _UnformattedID that correspond to FormattedID as this screenshot shows:
I noticed your are using fields and fetch . Per LBAPI's documentation, it uses fields rather than fetch. If you want to get all fields, use fields=true
As far as the missing custom fields, make sure that the custom field value was set within the dates of the query.
Compare these almost identical queries: the first query does not return a custom field, the second query does.
Query #1:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ProjectHierarchy":2222,"_TypeHierarchy":"PortfolioItem/Feature","State":"Developing",_ValidFrom: {$gte: "2013-06-01TZ",$lt: "2013-09-01TZ"}}}&fields=["_UnformattedID","Name","State","c_PiCustomField"]&hydrate=["State","c_PiCustomField"]
Query #2:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/11111/artifact/snapshot/query.js?find={"_ProjectHierarchy":2222,"_TypeHierarchy":"PortfolioItem/Feature","State":"Developing",__At: "current"}&fields=["_UnformattedID","Name","State","c_PiCustomField"]&hydrate=["State","c_PiCustomField"]
The first query uses time period: _ValidFrom: {$gte: "2013-06-01TZ",$lt: "2013-09-01TZ"}
The second query uses __At: "current"
Let's say I just create a new custom field on PortfolioItem. It is not possible to create a custom field on PorfolioItem/Feature, so the field is created on PI, but both queries still use "_TypeHierarchy":"PortfolioItem/Feature".
After I created this custom field, called PiCustomField, I set a value of that field for a specific Feature, F4.
The first query does not have a single snapshot that includes that field because that field did not exist in the time period we lookback. We can't change the past.
The second query returns this field for F4. It does not return it for other Features because all other Features do not have this field set.
Here is the screenshot: