cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
satishr Member
Member

How to retrieve and convert dates in custom visual?

Hi, I'm developing a custom visual where a bar chart should display values for last 15 days. I have date column and value column. I'm having a hard time retrieving the date values. Please help me.


I'm using table rows data view mapping. I need to retrieve these dates, convert them to a proper format, sort them and filter for latest 15 days.

 

I tried getting them as string as got text like this: Mon 1 Jan 2018 00:00:00 GMT +5.30 (Indian Standard Time)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator v-viig
Moderator

Re: How to retrieve and convert dates in custom visual?

You might use valueFormatter to format date to a proper format.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

3 REPLIES 3
Highlighted
Moderator v-viig
Moderator

Re: How to retrieve and convert dates in custom visual?

You might use valueFormatter to format date to a proper format.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

satishr Member
Member

Re: How to retrieve and convert dates in custom visual?

Implemented it. But it shows month number incorrectly.

 

var dateFormatter = ValueFormatter.create({format: "dd/mm/yyyy"});
var dateDisplay = minDateFormatter.format(myDate);

The result is 02/53/2018 instead of 02/02/2018. Why?
satishr Member
Member

Re: How to retrieve and convert dates in custom visual?

Solved the format problem. It should be "dd/MM/yyyy" instead of "dd/mm/yyyy". Small m represents minutes and capital M represents months. Thanks.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 6 members 1,888 guests
Please welcome our newest community members: