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
Espenblo
Frequent Visitor

Replacing a Datekey in integer format with todays date as integer

Hi,

 

I have a table with a datekey column as an integer on the form yyyymmdd. I want to replace the values 10010101 to today's date in power query. So today I will want to replace 10010101 to 20230609. Is there any way I can do this?

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi,

add Number.FromText

 Table.ReplaceValue(Previous_Step,10010101,Number.FromText(DateTime.ToText(DateTime.LocalNow(),"yyyyMMdd")),Replacer.ReplaceValue,{"Date"})

Stéphane 

View solution in original post

3 REPLIES 3
slorin
Super User
Super User

Hi,

add Number.FromText

 Table.ReplaceValue(Previous_Step,10010101,Number.FromText(DateTime.ToText(DateTime.LocalNow(),"yyyyMMdd")),Replacer.ReplaceValue,{"Date"})

Stéphane 

slorin
Super User
Super User

Hi,

 

= Table.ReplaceValue(Previous_Step,10010101,DateTime.ToText(DateTime.LocalNow(),"yyyyMMdd"),Replacer.ReplaceValue,{"Date"})

Stéphane 

I see that this solution returns the value as text, is it possible to change it to integer?

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.

Top Solution Authors
Top Kudoed Authors