Forum Discussion
date field not showing in console correctly
Hi jonespossibly,
Can you please provide your capabilities.json with the objects removed, so I can see your dataRoles and dataViewMappings?
Can you also please provide details of which version of powerbi-visuals-tools and powerbi-visuals-api that you're using?
This is probably going to be the easiest way to replicate, unless you have a public repo you can share.
Thanks,
Daniel
- jonespossibly4 years ago
Advocate I
{ "dataRoles": [ { "displayName": "Summary Row fields", "name": "summaryRowColumn", "kind": "GroupingOrMeasure" }, { "displayName": "Detail Row HTML", "name": "detailHTML", "kind": "GroupingOrMeasure" } ], "dataViewMappings": [ { "conditions": [ { "detailHTML": { "max": 1 } } ], "categorical": { "categories": { "select": [ { "for": { "in": "summaryRowColumn" } }, { "for": { "in": "detailHTML" } } ] } } } ] }
- dm-p4 years ago
Super User
Thanks - I was able to get your visual running and take a look 🙂
This is an interesting issue... it's the same in my visuals. So, probably a question for the team as to why it's the way it is. It doesn't make sense on the face of it, but both are valid if parsed.
In terms of formatting the date though, I usually test the metadata.type for the existence of the dateTime property, and instantiate a new Date() with the value if so (e.g. here).
This seems to work okay when formatting (using the format string in the format property):
So... sorry I can't answer why it's like that, but this might give you some ideas.
Regards,
Daniel
- jonespossibly4 years ago
Advocate I
Cheers Daniel.
And thanks for the code snippet. My main concern with the string values is that they use GMT and BST datetimes without an indication of them being part of that timezone.
So a date entered into power BI desktop, and set as a 'date' might be misinterpreted by a custom visual. So for instance, 01/01/2020 would come out as '2020-01-01T00:00:00.000Z' whereas 05/05/2019 would come through as '2019-05-04T23:00:00.000Z' - meaning that a custom visual might interpret that wrong. But I've just tried it through new Date and it seems like my worries were unfounded... 🙂
- jonespossibly4 years ago
Advocate I
"powerbi-visuals-api": "^3.8.4"