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

Date fields are shown as numbers even though mapping is set

Answered
Nikita asked on April 3, 2024

I have such values in a field - 2024-04-01 but it is always shown as a single number 2024. Is there a way to show it as a full date? Also, if we have more than 1 value for the field, can the values be shown comma-separated or it will always just be count of values? There can be null values, so I tried enforcing the type with the mapping:

getmapping: function (d) {
var mapping = {};
d.columns.forEach(function (col) {
if (!col.groupby && !scil.Utils.isNullOrEmpty(col.protocolid)) {
if (col.type == "float")
mapping[col.label] = { type: "number" };
else if (col.type == "date")
mapping[col.label] = { type: "date string" };
else if (col.type == "text")
mapping[col.label] = { type: "string" };
}
});
return mapping;
},

6 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 5, 2024

Hello, Nikita!

Thank you for writing to us.

This issue is probably caused by the mapping not being applied to the field containing dates. In such cases, Flexmonster assigns the default date type, which composes three hierarchical values for year, month, and day, as happens with the "Date1" field in this example: https://jsfiddle.net/flexmonster/6u2ngx5o/ 
We suggest printing the report retrieved with Flexmonster's getReport method and checking if the mapping is applied on a corresponding date field and the type is set to "date string".
Also, please note that Flexmonster does not support containing multiple comma-separated values in a single field.

Looking forward to hearing your feedback.

Best Regards,
Maksym

Public
Nikita April 5, 2024

I checked and the date is correctly set as "date string" but still shows incorrectly. Also, another field - ADME Assay/Admin Route - is set as "string" but it shows as count 1 and even when I click on the cell with 1 it still shows 1 instead of showing the value in the cell.
Wouldn't it work to just use customizeCell function to manually set comma-separated values for the fields that contain that data? 

Attachments:
flexview_date_type.png

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 8, 2024

Hello, Nikita!

Thank you for sharing more details with us.

From the provided screenshot, it looks like the mapping was set correctly. Yet, we were unable to reproduce the incorrect behavior when only the year is shown from a "date string" hierarchy. Could you please provide a reproducible code example where a field with a "date string" type is displayed as a year? 

Also, please note that only numeric values are supported in Flexmonster. Hence, when the string field is selected as a measure, the count is displayed as a default aggregation. Due to cell objects not saving the information about the strings from which the count value is composed, the workaround with customizeCell would not be possible to implement.

Looking forward to hearing from you.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 24, 2024

Hello, Nikita!

Hope you are doing well.
We are wondering if you were able to find the solution for the issue with mapping.
Please let us know if further assistance is needed.

Best Regards,
Maksym

Public
Nikita April 24, 2024

Hi Maksim,

We were able to just always show 'count', then use complex customizeCell function to show in parentheses the individual values for string types. We were not yet able to show dates correctly and most probably will need to format them manually too in customizeCell. Currently I am not working on the issues, but within 2 weeks will come back to it.

Thank you,

Nikita

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 25, 2024

Hello, Nikita!

Thank you for the reply.

We are glad you could implement the desired functionality for displaying string individual values. Speaking of the issue with displaying dates, we strongly recommend finding a solution to format them with mapping instead of using the customizeCell for date formatting. While the dates formatted this way may look correct, all the Flexmonster's aggregations and operations, like filtering and sorting, still rely on real cell data. This would cause inconsistency between labels and results of any operation.

Our team is ready to help with further research, so we kindly request you to provide a full runnable sample where the mentioned wrong mapping behavior can be reproduced. This would help us to identify the issue and provide a solution for it. Additionally, we have prepared an example with dates formatted as "YYYY-MM-DD" both in measure and members area: https://jsfiddle.net/flexmonster/ug91pn0x/ 

Our team is looking forward to hearing from you.

Best Regards,
Maksym

Please login or Register to Submit Answer