We have updated WebDataRocks EULA, effective as of April 18, 2024. Learn more about what's changed.

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

Answered

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 }
]

6 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

Eko PS October 6, 2019

Hello WDR,
I tried to set 

"nullValue": 0,

but the pivot result is blank/empty
but if I set

"nullValue": "0",

it is not number, but a Text/Char
https://i.ibb.co/YtMHz3q/ssss.png

WebDataRocks Team WebDataRocks October 8, 2019

Hello
Thank you for writing.
Yes, you are right. Currently, nullValue is a string and its value is exported to Excel as a Text/Char.
Please note that nullValue allows setting any chars or set of chars as a value. There is no option to define whether it is a number or not. That is the reason why it is always exported as a string.
Regards,
WebDataRocks Team