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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
maclura
Resolver I
Resolver I

List Item Type Conversion

All,

I would like to create my customized Date table with M.

My approach would be to calculate all the required colums (127 in total) as lists, and then generate the calendar table from those calculated lists.

Now, the issue is that I don't know how to set/alter data types for list items. Because I would like that when I generate the final calendar table each column has already its data type correctly set.

Until now the only poor solution I found is to define the data type when I create the table, but this doesn't fully address my need because I don't know how to set for a coumn a tata type like e.g. Int64.

 

Below a sample code

 

 

let
    StartDate = #date(2019,1,1),
    EndDate = #date(2021,12,31),
    DayCount = Duration.Days(EndDate - StartDate) + 1,

    Dates = List.Dates(StartDate, DayCount, #duration(1,0,0,0)),
    DateKey = List.Transform(Dates, each Date.Year(_) * 10000 + Date.Month(_) * 100 + Date.Day(_)),
    DayOfMonth = List.Transform(Dates, each Date.Day(_)),

    Calendar = Table.FromColumns(  
        {
            Dates,
            DateKey,
            DayOfMonth
        },
        type table[
            Date = date, 
            DateKey = number,
            DatOfMonth = number
        ]
    )
in
    Calendar

 

 

 

Any help would be greatly appreciated.

Thank you

m

 

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

Merely change your table definition to include that type:

 

        type table[
            Date = date, 
            DateKey = Int64.Type,
            DatOfMonth = Int64.Type
        ]

View solution in original post

1 REPLY 1
ronrsnfld
Super User
Super User

Merely change your table definition to include that type:

 

        type table[
            Date = date, 
            DateKey = Int64.Type,
            DatOfMonth = Int64.Type
        ]

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.