Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Datasource API and formulas

Answered
mp asked on April 23, 2020

Hello,
I’m experiencing problems when using measures defined by formulas and the datasource API.
For instance, in the following example https://jsfiddle.net/mp123456/34kqw8hn/1/,

  • The average price is not shown.
  • When trying to add two different measures (price and average) on the same field (price), the result is wrong.
  • However, when adding different measures on different fields (sum of price plus average of quantity) the result is fine.

Am I doing something wrong?
Thanks in advace.

7 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster April 23, 2020

Hello,
 
Thank you for contacting us.
 
Our team would like to kindly explain that there is no need to create the calculated value in order to specify some particular aggregation from the chosen hierarchy. It is enough to add the aggregation property and specify the desired aggregation as its value, for example:

{
"uniqueName": "Price",
"aggregation": "average"
}

 
Calculated values should be used when some additional calculations need to be applied on measures, in your case such hierarchies are named “Average Quantity plus Total Price” and “Total plus Average Price”.
 
We have modified your example in the way everything work as expected. It is achievable using the approach described above instead of creating a new calculated value for each required aggregation.
 
We recommend referring to our tutorial on configuring the slice object in order to get more information about the recommended ways to choose hierarchies to display and adjust them in the desired way.
 
Our team sure hopes it helps.
Do not hesitate to contact us in case additional questions occur.
 
Best regards,
Illia

Public
mp April 24, 2020

Hello,
Thank you for the response. I agree that individual computations such as “sum(‘Price’)” are more easily computed with an aggregation instead of a formula.
However, the example just intended to show that the application sometimes fails to retrieve the desired data. I just build a simple example with your sample data so that you can see the error I get.
In the original example, in the POST request named “select”, it can be seen that the average of price is never asked for, and I think this is not the behaviour to be expected.
I’ve copied the POST request I refer to:
{“index”:”fm-product-sales”,”page”:0,”query”:{“aggs”:{“by”:{“cols”:[{“uniqueName”:”Category”}],”rows”:[{“uniqueName”:”Country”}]},”values”:[{“field”:{“uniqueName”:”Price”},”func”:”sum”},{“field”:{“uniqueName”:”Price”},”func”:”sum”},{“field”:{“uniqueName”:”Price”},”func”:”sum”},{“field”:{“uniqueName”:”Price”},”func”:”sum”},{“field”:{“uniqueName”:”Quantity”},”func”:”average”},{“field”:{“uniqueName”:”Quantity”},”func”:”average”},{“field”:{“uniqueName”:”Price”},”func”:”sum”}]}},”type”:”select”}
Thank you for your help.
Best regards

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster April 24, 2020

Hello,
 
Thank you for the detailed information about the problem.
 
Our team is going to research the issue.
We will provide you with results ETA May 18.
 
You are welcome to contact us in case any other questions arise.
 
Best regards,
Illia

Public
mp April 24, 2020

Hello,
Thank you, I look forward to your response.
Best regards

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster May 20, 2020

Hello,
 
We are pleased to inform you that the issue with missed measures in the calculated values was fixed.
 
This is provided in the 2.8.7 version of Flexmonster: https://www.flexmonster.com/release-notes/.
 
You are welcome to update the component.
Here is our updating to the latest version guide for assistance: https://www.flexmonster.com/doc/updating-to-the-latest-version/.
 
Please let us know if everything works fine for you.
 
Best regards

Public
mp May 21, 2020

Hello,
Thank you for the update, I will try it out.
Best regards

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster June 2, 2020

Hello,
 
Our team is wondering whether our fix did manage to resolve the problem with missed measures in the calculated values.
 
We are looking forward to hearing from you.
 
Kind regards,
Illia

Please login or Register to Submit Answer