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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Tim_Groothuis
Regular Visitor

Generating a TimeGenerated column from the Source.Name

Hello all,

 

I'm fairly new to powerBi and I couldn't figure out how to get this working in power Query. 

I have a dataset like this:

Source.NameDeviceCount
Devices20230508.json215
Devices20230509.json213
Devices20230510.json218
Devices20230511.json221

As you can see, the Source.Name is time stamped (8th of may, 9th of may, etc.) I want to generate a time column based on the content of the Source.Name column. Below would be my desired result:

Source.NameDeviceCountTime Generated
Devices20230508.json2152023-05-08
Devices20230509.json2132023-05-09
Devices20230510.json2182023-05-10
Devices20230511.json2212023-05-11

Any help would be greatly appreciated. Thanks!

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Tim_Groothuis ,

 

Add this as a new custom column:

let numbers = Text.Select([Source.Name], {"0".."9"}) in
#date(
    Number.From(Text.Start(numbers, 4)),
    Number.From(Text.Middle(numbers, 4, 2)),
    Number.From(Text.End(numbers, 2))
)

 

For this output:

BA_Pete_0-1684145311120.png

 

Full example query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wckkty0xOLTYyMDI2MDWw0Msqzs9TitVBljAyNDIyhUrEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Source.Name = _t]),
    addTimeGenerated =
        Table.AddColumn(
            Source,
            "Time Generated",
            each let numbers = Text.Select([Source.Name], {"0".."9"}) in
            #date(
                Number.From(Text.Start(numbers, 4)),
                Number.From(Text.Middle(numbers, 4, 2)),
                Number.From(Text.End(numbers, 2))
            )
        )
in
    addTimeGenerated

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @Tim_Groothuis ,

 

Add this as a new custom column:

let numbers = Text.Select([Source.Name], {"0".."9"}) in
#date(
    Number.From(Text.Start(numbers, 4)),
    Number.From(Text.Middle(numbers, 4, 2)),
    Number.From(Text.End(numbers, 2))
)

 

For this output:

BA_Pete_0-1684145311120.png

 

Full example query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wckkty0xOLTYyMDI2MDWw0Msqzs9TitVBljAyNDIyhUrEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Source.Name = _t]),
    addTimeGenerated =
        Table.AddColumn(
            Source,
            "Time Generated",
            each let numbers = Text.Select([Source.Name], {"0".."9"}) in
            #date(
                Number.From(Text.Start(numbers, 4)),
                Number.From(Text.Middle(numbers, 4, 2)),
                Number.From(Text.End(numbers, 2))
            )
        )
in
    addTimeGenerated

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi Pete,

Awesome, thank you so much for your help! You saved me a lot of headache! 

Tim

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.