Why are all cells rendered as "0", when all datasource values are null?

Resolved

Hello.
Problem: when all “SoldQuantity” values are null, null value cells are rendered as “0”, not as “”.
When at least one “SoldQuantity” value is not null, null value cells are rendered as “”.
Datasources:

[
{ "ItemName": "Item1", "SoldQuantity": 10 },
{ "ItemName": "Item2", "SoldQuantity": null }
]

[
{ "ItemName": "Item1", "SoldQuantity": null },
{ "ItemName": "Item2", "SoldQuantity": null }
]

4 answers

WebDataRocks Team WebDataRocks May 30, 2019

Hi Edvinas,
Thank you for your question.

This behavior can be explained by the specifics of the way the component is implemented.
The pivot table component tries to automatically infer the data type by analyzing the first object in the data source.
In case the value of the particular field in the first object is null, the component interprets this field as string and applies the count aggregation to it. The fields with numerical values in the other objects are also interpreted as strings.
In case the value of the particular field in the first object is a number, then the component interprets this field as numerical and allows applying aggregations for numbers (sum, average, etc).
To make the component interpret the field the way you need, you need to set data types explicitly. Please refer to our guides:

In this demo you can check how to set the data types. 

Hope this is helpful for your case.

Best regards,
WebDataRocks Team

Edvinas May 30, 2019

Thanks for great answer! That’s what I was looking for.

Edvinas June 2, 2019

One more question.
Using function getDataWithTypes() in provided demo, I set all SoldQuantity values to null. Item rows are gone. I still need to see them, but with empty values. Can I make that happen?

WebDataRocks Team WebDataRocks June 5, 2019

Hello Edvinas,
Thank you for writing. WebDataRocks automatically excludes null values from the report.
If you need the values to be available in the report you can either replace null values with 0 or switch to the flat form.
Regards,
WebDataRocks Team

Please login or Register to Submit Answer