How can I calculate percentages with a distinctcount()?

Answered
Bernat Pinós asked on October 26, 2018

Hello,
 
We need to show percentages of rows and columns as it appears in the image. However, our values are counted by a distinctcount(), which isn’t detected by the percentofrow() and percentofcolumn() formulas and then, they get a result from a count(). In a nutshell, the distinctcount() is completely omitted by the formulas. This problem causes some percentage errors as you can see in the image.
 

In this case, this error happens because the count() total is 3153 and the distinctcount() total is 3144.
 
We have tried to approach this problem by, instead of using the two percentage formulas, creating one new column (or row, depending on which percentage we are calculating) which contains only the same value in each cell of the column. This value will be the total of a distinctcount(“nif_nie”), for example, the value in the (2,12) cell:

With this column, we could simply divide the 2nd column with this one and get the percentage of column with a distinctcount() instead of a count(). The question is: which formula do we have to write to get the total of the 2nd column, and fill all the new column with this same value?
 
On a slightly different note, I want to ask you another question. Apart from using your tool and getting benefit from its dynamics, we have also put it into an HTML in order to print the page from a browser. When printing the page, everything looks a bit narrower. Is it possible to make the cell grey lines a little bit thicker? And is it possible to hide the index numbers (the numbers that determine in which column and row a cell is)?
 
Thank you so much for your attention.

4 answers

Public
Bernat Pinós October 26, 2018

I’m attaching both pictures here in case of not being able to load them.

Public
Tanya Gryshko Flexmonster October 26, 2018

Hello, Bernat,
Thank you for writing to us.
We would like to provide some explanations on how percentages are calculated in our component. percentofcolumn(), percentofrow() and percent() aggregations are always applied to the raw data values, not to the aggregated data from the previous column. This means that the aggregation applied to Recompte... does not affect the resulting values of % FILA. These percentage aggregations are always calculated based on sum() aggregation. Hope this explanation helps. As about getting the total value of the 2nd column, it is not possible to address specific cells when creating a calculated value.

Regarding the ability to make the cell grey lines a little bit thicker, it can be done via custom CSS styles. Please see our recommendations about this approach: Customizing appearance.

Hiding of the index numbers is also possible in our component. For this purpose, we have a showHeaders option. Please have a look at this example: http://jsfiddle.net/flexmonster/fe2k6m8y/75/.
It can also be useful to have a look at other available options: Options Object.
Please let me know in case of any other questions.
Regards,
Tanya

Public
Bernat Pinós October 31, 2018

Hello Tanya,

I have encountered some problems with making the grey cell lines wider and setting the showHeaders option to false. As about the grey lines, I have managed to change the CSS from the “flexmonster.css” file to make them wider, however, it only works fine for Firefox. When I load a table in Chrome, no changes appear to be applied. Why does this happen?

Regarding the showHeaders option, as you can see in the attached image I have added the necessary code to set it to false, however, it is not applied at all. What can I do?

Thank you,
Bernat

Attachments:
showHeaders.JPG

Public
Iryna Kulchytska Flexmonster November 1, 2018

Hi Bernat,
 
Thank you for your questions.
 

Regarding the showHeaders option, as I can see in the image, the property was set as "showHeaders": "false" (a string “false”), but it should be set as "showHeaders": false (boolean false).
 
Regarding making the grey cell lines wider using CSS, we have prepared a basic example of how this can be done: https://jsfiddle.net/flexmonster/58gzsxvf/
Additionally, more JSFiddle examples on how to configure the look and feel of Flexmonster Pivot by adding custom CSS styles can be found here: https://www.flexmonster.com/examples/#!custom-css
Please note that we recommend writing your custom CSS code in a separate file (e.g. my-flexmonster-styles.css) and keep the original styles in flexmonster.css without changes. This will ensure that the updates to the newer versions of the component will be simple and smooth.
 
Please let me know if the above helps with your questions.
 
Kind regards,
Iryna

Please login or Register to Submit Answer