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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Porkey
Frequent Visitor

Need help inserting specific date from same row into the table

Porkey_1-1688654407134.png

 

I want to insert the date from row 1 into the Table on row one, the code ive used has inserted the dates as a list so they are all present. Is there a waty to get just the date from that row into the table?

 

Table.AddColumn(
                #"Invoked Custom Function", 
                "Custom", 
                 each Table.AddColumn(
                                       [ContentAdder],  
                                       "Date",
                                        each #"Invoked Custom Function"[Date],
                                        type date
                                       )
                )

 

edit: the date comes from the file name

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

You need to trap that value (date) in a variable first, then reference the variable inside the Table.AddColumn. Something like this:

 

Table.AddColumn(
                #"Invoked Custom Function", 
                "Custom", 

                 each 
				 	let
						varDate = [Date]
					in
					Table.AddColumn(
                                       [ContentAdder],  
                                       "Date",
                                        each varDate,
                                        type date
                                       )
                )


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
AlienSx
Super User
Super User

Table.AddColumn(
    #"Invoked Custom Function", 
    "Custom", 
    (x) => 
        Table.AddColumn(
            x[ContentAdder],  
            "Date",
            (y) => x[Date],
            type date
        )
)
edhans
Community Champion
Community Champion

You need to trap that value (date) in a variable first, then reference the variable inside the Table.AddColumn. Something like this:

 

Table.AddColumn(
                #"Invoked Custom Function", 
                "Custom", 

                 each 
				 	let
						varDate = [Date]
					in
					Table.AddColumn(
                                       [ContentAdder],  
                                       "Date",
                                        each varDate,
                                        type date
                                       )
                )


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Porkey
Frequent Visitor

Thank you very much. 
Can i ask why it needs to be trapped in a variable? or if you cold point me to some reading that would explain.

 

 

edhans
Community Champion
Community Champion

In trapping the variable the way I did, I got the value outside of the context of the next Table.AddColumn() function. You can read more about it here. M Language basic concepts - PowerQuery M | Microsoft Learn

But it is similar to using a variable in DAX to trap values at an outer context vs using EARLIER() in the inner context. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 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.