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

Problem when displaying different types of values for same field

Resolved
Javier Sanz Lopez asked on April 8, 2020

Hello!
I am currently having a problem with my flexmonster table. I have two types of data under KPIType (GWP and Policy). One is an amount and the other is just a normal sum. To give the result two different formats, I created two different values: value and quantity. Depending on the type it will have one or the other. Here is an example of the two.

{"kpitype": "GWP","lineOfBusiness": "Life","segment": "Cancellation","startDate": "2018-12-31T23:00:00.000Z","endDate": "2019-03-30T23:00:00.000Z","timePeriod": "Acc. 1.1 to date 2019","quantity": 239974.59000000003},
{"kpitype": "Policy","lineOfBusiness": "Health","segment": "Replacement","startDate": "2017-12-31T23:00:00.000Z","endDate": "2018-03-30T22:00:00.000Z","timePeriod": "Acc. 1.1 to date 2018","value": 754},

And here is the complete slice:
const report = {
      dataSource: {
        type: 'json'
      },
      formats: [
        {
          name: 'currency',
          decimalPlaces: 2,
          currencySymbol: '€',
          positiveCurrencyFormat: '1$',
          nullValue: '',
        },
        {uniqueName: 'normal'}
      ],
      slice: {
        rows: [{
          uniqueName: 'kpitype',
        },{
          uniqueName: 'segment'
        },
       ],
        columns: [{
          uniqueName: 'timePeriod'
        },
        {
          uniqueName: '[Measures]'
        }],
        measures: [
          {
            uniqueName: 'quantity',
            format: 'currency',
            active: 'true',
          },
          {
            uniqueName: 'value',
            active: 'true',
          },
        ],
        expands: {
          expandAll: true
        }
      },
      options: {
        configuratorActive: false,
        showGrandTotals: false,
      }
    };
When I create the table like this, only one of them appears, and to get them both I have to at least add both values in one of them. You can see the result in the attached image. Why is that? Do I have to add both values in all of my JSON? Is there a way to format just each kpiType and show them all together only using one value?.
Thanks a lot and best regards.
Javier

Attachments:
8Apr2020.png

2 answers

Public
Vera Didenko Vera Didenko Flexmonster April 9, 2020

Hello, Javier,
 
Thank you for writing to us.
 
Please kindly note that each data record should contain the same set of fields. 

If we understand correctly, you would like to format the value differently for GWP and Policy.
For such a case, we kindly suggest customizing the way the values are displayed via the customizeCell() API call
With such an approach you can adjust the representation of the value based on the corresponding field's member.

Please check out the following JSFiddle for illustration: https://jsfiddle.net/flexmonster/dtry1kzm/

In the example, the value field is represented by one measure ("value") instead of two ("quantity" and "value").
Then via customizeCell the "value" cells are customized depending on which member they correspond to (GWP or Policy).
 
Please let us know if this works. 
 
You are welcome to write to us in case additional questions arise.
 
Kind regards,
Vera

Public
Javier Sanz Lopez April 14, 2020

Good morning Vera.
I tried it out and it seems like it will work perfectly for what we are trying to achieve. Thanks for everything and for the quick answer.
Best regards.
Javier.

Please login or Register to Submit Answer