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
AbhinavJoshi
Responsive Resident
Responsive Resident

Reference a query in the source step

Hello,

 

I would like to reference a query or a parameter in the source step. I am using sharepoint as my data source. I would like to get the current month and year value that changes every month (dynamically) in my source step. The format I would like Year-Month (Ex: 2023-10)

 

What I would like to achieve 

 

= Excel.Workbook(Web.Contents("www.mysharepoint.com" +  "Current Month and Year Parameter" + "FileName"), null, true)

 

I have made a query that gives me the value but I don't no how to reference it in the source step, here is the code for query.


let
currentDate = Date.From(DateTime.LocalNow()),
Custom1 = {currentDate},
#"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Split Column by Position" = Table.SplitColumn(Table.TransformColumnTypes(#"Converted to Table", {{"Column1", type text}}, "en-CA"), "Column1", Splitter.SplitTextByPositions({0, 7}, false), {"Column1.1", "Column1.2"}),
#"Removed Columns" = Table.RemoveColumns(#"Split Column by Position",{"Column1.2"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Column1.1", "Date"}}),
Custom2 = {#"Renamed Columns"}
in
Custom2

 

Thank you in advance for the help,

Abhinav

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@AbhinavJoshi , You can get a date in the format like

 

= Excel.Workbook(Web.Contents("www.mysharepoint.com"  & Date.ToText(DateTime.LocalNow(), "yyyy-MM") &  "FileName"), null, true)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
AbhinavJoshi
Responsive Resident
Responsive Resident

Thanks @amitchandak . It intially gave me an error: We cannot convert the value #datetime(2023, 10, 18, 11, 6, 4.7513611) to type Date. But I passed Date.ToText(Date.From(DateTime.LocalNow())) instead of Date.ToText(DateTime.LocalNow(), "yyyy-MM")

Have a great day!

amitchandak
Super User
Super User

@AbhinavJoshi , You can get a date in the format like

 

= Excel.Workbook(Web.Contents("www.mysharepoint.com"  & Date.ToText(DateTime.LocalNow(), "yyyy-MM") &  "FileName"), null, true)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.