Search code examples
powerbipowerquerypowerbi-desktopmodelingm

List Dates and customizing tables in Power Query


I'm trying to Add Custom Column in Power Query with the objective to return a Table from a List of dates.

The syntax used is as follows below:

= Table.AddColumn(TypeDate, "AddTable", each Table.FromList(
    List.Dates([Date_begin],1,#duration(1,0,0,0)
    )))

where:

  1. TypeDate is the name of last step in Power Query
  2. "AddTable" is the name of added custom column
  3. [Date_begin] is a column with dates to be considered as the start of my list

Although the syntax seems correct, Power Query returns an error described as follows:

Expression.Error: We could not convert the value #date(2021, 1, 1) on to Text.
Details:
    Value=01/01/2021
    Type=[Type]

Does anyone know how to handle this problem? I'll show an image where Power Query shows the error.

Select here to see Power Query interface


Solution

  • Your question is unclear

    You want to add a column that has a table of dates for each row, using Date_Begin and Mes_Final?

    #"Added Custom" = Table.AddColumn(TypeDate, "AddTable", each Table.TransformColumnTypes(Table.FromList({Number.From([Date_Begin])..Number.From([Mes_Final])}, Splitter.SplitByNothing(), {"date"}),{{"date", type date}}))   
    

    enter image description here