Forum Discussion
date field not showing in console correctly
I'm currrently passing a data field into a custom visualisation of type 'Date'
I can see from the dataview in the custom vis toolbar that it is passed through as a bunch of functions and a epoch timestamp:
but when i try and log the same data from the options variable passed through to the public update function, i sse this:
what is going on here? and how do i successfully format that date as specified in the data model?
6 Replies
- dm-pSuper User
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
- jonespossiblyAdvocate 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-pSuper 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
- jonespossiblyAdvocate I"powerbi-visuals-api": "^3.8.4"
- jonespossiblyAdvocate I
ok, this really is weird.
the data role of the well is "grouping".
if you put the date field into the well first, then it retains its date type functions.
if you put it in after another field, it turns the date types into strings.
what on earth???