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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
satishr
Helper III
Helper III

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
v-viig
Community Champion
Community Champion

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

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

3 REPLIES 3
v-viig
Community Champion
Community Champion

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

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

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?

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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