cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jonespossibly
Helper I
Helper I

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:

jonespossibly_0-1645489229327.png

but when i try and log the same data from the options variable passed through to the public update function, i sse this:

jonespossibly_2-1645489367801.png

what is going on here?  and how do i successfully format that date as specified in the data model?

 

6 REPLIES 6
dm-p
Super User
Super 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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




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

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):

dmp_0-1646358285846.png

So... sorry I can't answer why it's like that, but this might give you some ideas.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




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...  🙂

jonespossibly
Helper I
Helper 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.

jonespossibly_0-1645546363615.png

 

jonespossibly_1-1645546394736.png

 

what on earth???

 

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors