Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jonespossibly
Advocate I
Advocate 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
Advocate I
Advocate 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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors