Need a special offer?Find out if your project fits.
+

Issue with formula

Answered
Jaffrezic asked on July 5, 2021

Hi 
I have an issue with formula, it doesn't execute the formula.
it works fine with 2.4
https://jsfiddle.net/Jaffrezic/swa2onhp/11/
but it doesn't work with
https://jsfiddle.net/Jaffrezic/swa2onhp/10/
 
Franck

3 answers

Public
Vera Didenko Vera Didenko Flexmonster July 6, 2021

Hello, Franck,
 
Thank you for providing JSFiddle examples for reference.
 
In the JSFiddles, we noticed that you are creating a new calculated measure using an existing uniqueName - measure_5:

// The dataset:
[
{
dimension_0: 'ma pharmacie',
dimension_1: undefined,
Fidélité: '',
measure_3: 23990,
measure_4: 4976,
measure_5: 26.17
},
...
]


// The calculated measure:
{
uniqueName: "measure_5",
caption: "Quantité vendue result",
formula: "(sum('measure_4')/(sum('measure_3')-sum('measure_4')))*100)"
}

This seems to be causing the issue since each measure should have its own unique uniqueName. With this in mind, we suggest providing a different uniqueName for the new calculated measure, for example:

// The dataset:
[
{
dimension_0: 'ma pharmacie',
dimension_1: undefined,
Fidélité: '',
measure_3: 23990,
measure_4: 4976,
measure_5: 26.17
},
...
]


// The calculated measure:
{
uniqueName: "measure_6",
caption: "Quantité vendue result",
formula: "(sum('measure_4')/(sum('measure_3')-sum('measure_4')))*100)"
}

Afterward, the formula should work correctly. Here is a modified version of the JSFiddle for reference: https://jsfiddle.net/flexmonster/okbm1tqw/.
 
Please let us know if this works.
 
Kind regards,
Vera

Public
Jaffrezic July 6, 2021

Hi Vera
Thank for your answer.
Could you explain to me why it works with 
it works fine with 2.4
https://jsfiddle.net/Jaffrezic/swa2onhp/11/
Franck

Public
Vera Didenko Vera Didenko Flexmonster July 6, 2021

Hello, Franck,
 
Thank you for your reply.
 
As we see in 2.4, there was some sort of backdoor that allowed to override an existing field in the dataset by assigning its uniqueName to a calculated measure. However, this is not the expected behavior, and in the later versions of Flexmonster, this has been fixed. Therefore, a new uniqueName should be used when creating a calculated measure.
 
We hope this helps. Feel free to reach out if other questions arise.
 
Kind regards,
Vera

Please login or Register to Submit Answer