Is it possible to get From-To Date parameter difference in minutes in Dundas BI? I want to calculate Lost Opportunity in Dashboard which will show Total Available Minutes in between From-To date to Actual Cycle Time (in minutes).?
Get Date Parameter From-To Date difference in Minutes
From what I have seen, if you allow tokens then it is not always possible as sometimes when you pull the parameter script value it will return ‘Today’ for example. If you don’t allow tokens and only allow dates, then you can retrieve the parameter values by script and subtract the dates. If anyone has found a way around this, please let me know.
As of version 6 there is a ‘resolve’ method on all parameter values, which you can read in our API docs here.
But essentially you can do something like this:
var viewParameter = this.parentView.control.viewParameters[1];
var metricSetId = viewParameter.getMetricSetBindingsFromLinks(this.parentView)[0].metricSetBinding.metricSetId;
viewParameter.parameterValue.resolve(metricSetId).done(function (resolvedParameterValue) {
// resolvedParameterValue will have the discreet values in the correct boundary value or main value
});
This allows you to resolve tokens to discreet values.
If your parameter value already has the values in it (no tokens), then you can usually just use lowerBoundaryValue
and upperBoundaryValue
if it’s a RangeDateTimeValue. These are found in the above example on viewParameter.parameterValue
.
If it’s a SingleValue then value
will have it instead.
If it’s a different type, such as a calendar control using a hierarchy and CollectionMemberValue or RangeMemberValue, then you’ll need to get the member using our hierarchy service and the member value will contain properties for memberTime and upperBoundaryTime.
Please be very careful when you work with dates in JavaScript as it does not have good date support, and even something as simple as new Date()
being sent to the server may result in an incorrect data result as the date will likely (in most browsers such as Chrome) be shifted by your locale time zone when it’s serialized. You should always send zulu-time (UTC) to the server.