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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
kerwin73
New Member

Basic syntax question - using List.Dates function

Hi,

There are many responses to similar questions on this board, but unfortunately I am completely lost on how to implement.

I am attempting to create a new column that I can expand. I believe I can use the List.Dates function to create the column and nested table. The nested table will have an incremented date between the start and end dates.

Can you please help, I believe my syntax is incorrect.

 

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

  I believe this is related to 2nd argument in Custom1 ... however, unknown to me how to resolve.

Code:

 

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = List.Dates([pse__Start_Date__c], [pse__End_Date__c]-[pse__Start_Date__c]+1,#duration(1,0,0,0))
in
    Custom1

 

 

 

1 ACCEPTED SOLUTION
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @kerwin73 - The error message is attempting to explain that does not know where to find the columns used in your List.Dates function.  For example, [pse_Start_Date__c] is a column in the Object called #"Extracted Date1".  But Power Query does know this.  To help, I need to understand how many rows are included in the Table. 

If it is just one, then this might work.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = List.Dates(
         List.Min( #"Extracted Date1"[pse__Start_Date__c]),
         Number.From ( 
             List.Min( #"Extracted Date1"[pse__End_Date__c] ) - 
                List.Min( #"Extracted Date1"[pse__Start_Date__c] ) + 1,
         #duration(1,0,0,0)
    )
in
    Custom1

 If there are multiple rows, then this would work.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = Table.AddColumn( #"Extracted Date1" , "DateList", each
         List.Dates(
           [pse__Start_Date__c]),
           Number.From ( [pse__End_Date__c] - [pse__Start_Date__c] ) + 1,
           #duration(1,0,0,0) 
         )
    )
in
    Custom1

 

View solution in original post

4 REPLIES 4
kerwin73
New Member

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = Table.AddColumn( #"Extracted Date1" , "DateList", each
         List.Dates(
           ([pse__Start_Date__c]),
           Number.From ( [pse__End_Date__c] - [pse__Start_Date__c] ) + 1,
           #duration(1,0,0,0) 
         )
    ),
    #"Expanded DateList" = Table.ExpandListColumn(Custom1, "DateList")
in
    #"Expanded DateList"
kerwin73
New Member

Apologies, reading closer, even a basic syntax issue I could figure out.

Missing open parenthesis around start date field, then added back your final close paren on custom function.

 

Thanks @Daryl-Lynch-Bzy 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = Table.AddColumn( #"Extracted Date1" , "DateList", each
         List.Dates(
           ([pse__Start_Date__c]),
           Number.From ( [pse__End_Date__c] - [pse__Start_Date__c] ) + 1,
           #duration(1,0,0,0) 
         )
    ),
    #"Expanded DateList" = Table.ExpandListColumn(Custom1, "DateList")
in
    #"Expanded DateList"

 

kerwin73
New Member

@Daryl-Lynch-Bzy - thank you so much for giving this basic question your attention.

The step you suggest appears to have gotten me closer, but not all the way to desired end state.

It is likely that my description is/was incomplete (see additional context below). 

 

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

Full snippet, less your final ")" which was generating expected comma error.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = Table.AddColumn( #"Extracted Date1" , "DateList", each
         List.Dates(
           [pse__Start_Date__c]),
           Number.From ( [pse__End_Date__c] - [pse__Start_Date__c] ) + 1,
           #duration(1,0,0,0) 
         )
in
    Custom1

More context:

Data set pre custom function:

Project NameTask NameBG_WBS_Number__cSum of pse__Estimated_Hours__cpse__Start_Date__cpse__End_Date__c
Project 1Task 110.10.20 - Project Management101/20/20231/26/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/2023
Project 1Task 310.10.20 - Project Management41/24/20231/24/2023

 

Desired data set post custom function:

Project NameTask NameBG_WBS_Number__cSum of pse__Estimated_Hours__cpse__Start_Date__cpse__End_Date__cDateList
Project 1Task 110.10.20 - Project Management101/20/20231/26/20231/20/2023
Project 1Task 110.10.20 - Project Management101/20/20231/26/20231/21/2023
Project 1Task 110.10.20 - Project Management101/20/20231/26/20231/22/2023
Project 1Task 110.10.20 - Project Management101/20/20231/26/20231/23/2023
Project 1Task 110.10.20 - Project Management101/20/20231/26/20231/24/2023
Project 1Task 110.10.20 - Project Management101/20/20231/26/20231/25/2023
Project 1Task 110.10.20 - Project Management101/20/20231/26/20231/26/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/1/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/2/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/3/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/4/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/5/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/6/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/7/2023
Project 1Task 210.10.20 - Project Management402/1/20233/28/20232/8/2023
      Etc…

 

 

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @kerwin73 - The error message is attempting to explain that does not know where to find the columns used in your List.Dates function.  For example, [pse_Start_Date__c] is a column in the Object called #"Extracted Date1".  But Power Query does know this.  To help, I need to understand how many rows are included in the Table. 

If it is just one, then this might work.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = List.Dates(
         List.Min( #"Extracted Date1"[pse__Start_Date__c]),
         Number.From ( 
             List.Min( #"Extracted Date1"[pse__End_Date__c] ) - 
                List.Min( #"Extracted Date1"[pse__Start_Date__c] ) + 1,
         #duration(1,0,0,0)
    )
in
    Custom1

 If there are multiple rows, then this would work.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Date1" = Table.TransformColumns(Source,{{"pse__Start_Date__c", DateTime.Date, type date}, {"pse__End_Date__c", DateTime.Date, type date}}),
    Custom1 = Table.AddColumn( #"Extracted Date1" , "DateList", each
         List.Dates(
           [pse__Start_Date__c]),
           Number.From ( [pse__End_Date__c] - [pse__Start_Date__c] ) + 1,
           #duration(1,0,0,0) 
         )
    )
in
    Custom1

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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