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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Jimbo1980
Regular Visitor

Create a date Variable in excel and get power query to repeat that date over all rows in a table

I have a table with approx 6,000 rows. Then I have a report date in excel i.e. the date I run the report e.g. 22/07/2024.  What I want to do is to refer to the date I run the report so I can perform calculations in the 6,000 rows. The report date is essentially a variable thats sits in excel and changes. I have tried a few things like importing the date as connection only, then adding a column with the reference for the report date variable but to no avail. 

 

Any advise is much appreciated. I am sure there must be a way but I cannot figure it out!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Jimbo1980 ,

 

After I reviewed again, I understand that you want call a column from another table.

Try adding a custom column. #"tablename"[columnname]. 

#"Table (2)"[ReportDate]

[RpoertDate] is in Table(2).

vstephenmsft_3-1722584919025.png

vstephenmsft_0-1722584785603.png

Expand it.

vstephenmsft_1-1722584860023.png

You can see the [ReportDate] from Table(2) now is in Table.

vstephenmsft_2-1722584865486.png

 

Similar post:Solved: How to reference another table in Query Editor (M) - Microsoft Fabric Community

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

8 REPLIES 8
PwerQueryKees
Super User
Super User

I don't have access to my laptop at the moment. But ...

  • Make a new empty query.
  • Enter the formula Excel.CurrentWorkbook()
  • This will show you all the accessible content 
  • Find your named range
  • Click on the value in the content column
  • If it appears as a table, you may need to drill down until it just goes the date.

Give you query a name and you can use it in any expression...

so i have managed to add the report date as a query, I have drilled down. The reference for the date in power query appears to be '= #"Changed Type"{0}[Column1]'. But then if I go into another query how do i reference this report date query?

 

PwerQueryKees
Super User
Super User

Make a named range in Excel that refers to the report run date. You can access this named range inpiwerquery as a separate query. You may want to transform it a bit depending on how you want to use it. Assuming you transform it to produce just the actual date value, you can use the name of your query anywhere you want the report run date.

Hi thanks for your reply, 

 

So i have made a named range in excel called 'Report_Date' which refers to cell B2 the date (22/07/2024). But how do i refer to that variable in power query? 

Anonymous
Not applicable

Hi @Jimbo1980 ,

 

Thanks for reaching out to the community.

To get the current date in Power Query, you can use the expression “= DateTime.Date (DateTime.LocalNow ())” in the Formula Bar. This generates the current datetime value in Power Query by using the DateTime.LocalNow function, which looks at the current date and time on your system.

DateTime.LocalNow - PowerQuery M | Microsoft Learn

How to Create Today's Date in Power Query M (gorilla.bi)

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi Stephen, 

Thank you for your reply but unfortunately the current date isn't what I am looking for. I need to create a variable which I can type the report date in (This could be a date in the past). Then I can use this variable or object to refer to in my table of 6,000 rows to perform the necessary calculations.

Anonymous
Not applicable

Hi @Jimbo1980 ,

 

After I reviewed again, I understand that you want call a column from another table.

Try adding a custom column. #"tablename"[columnname]. 

#"Table (2)"[ReportDate]

[RpoertDate] is in Table(2).

vstephenmsft_3-1722584919025.png

vstephenmsft_0-1722584785603.png

Expand it.

vstephenmsft_1-1722584860023.png

You can see the [ReportDate] from Table(2) now is in Table.

vstephenmsft_2-1722584865486.png

 

Similar post:Solved: How to reference another table in Query Editor (M) - Microsoft Fabric Community

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks for that Stephen that worked!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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