Source file in shared OneDrive folder depends on local drive

DRSteele

Well-known Member
Joined
Mar 31, 2015
Messages
2,640
Office Version
  1. 365
Platform
  1. Windows
Can someone please help me?

I (DRS) have a file stored in a shared folder in OneDrive that contains some queries. The sources for the queries are CSV files stored in that folder's sub-folder in OneDrive and are updated regularly. So the source looks like this:

C:\Users\DRS\OneDrive\DRS_JRS\Investments\JRS_StockData\UntitledWatchList-stocksAndEtfs.csv

When I attempt to open the file using JRS's computer, I get "DataSource.Error: Could not find a part of the path...."

JRS is forced to alter the queries to C:\Users\JRS\etc to get the queries to function; this is unworkable. I hope someone can provide a solution or suggestions.

Thanks in advance.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Thanks for your prompt reply. I read through and attempted the code in Allington's blog. I've struggled heroically but I'm clearly out of my depth. Can you help me more please?

1) I created a table (Table3) in my workbook (the one that gets shared).

FGH
4typeuservalue
5CurrentUserDRS
6DataStocksDRSC:\Users\DRS\SkyDrive\DRS_JRS\Investments\JRS_StockData
7DataStocksJRSC:\Users\JRS\OneDrive\DRS_JRS\Investments\JRS_StockData

<tbody>
</tbody>
query



2) I then created the Function to invoke for the Stocks file. I called it ParametersStocks:

let
ParametersStocks = (myParameter) =>

let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
MyUser = Table.SelectRows(Source, each ([user] = null)),
MyUserValue=Record.Field(MyUser{0},"value"),
#"Filtered Rows" = Table.SelectRows(Source, each ([user] = MyUserValue) and ([type] =myParameter)),
MyReturnedParameter=Record.Field(#"Filtered Rows"{0},"value")
in
MyReturnedParameter,
#"Invoked FunctionParametersStocks" = ParametersStocks("DataStocks")
in
#"Invoked FunctionParametersStocks"


3) So far so good, I think. I then altered the query for Stocks to this, and it fails. The error is "Expression.Error: We cannot convert the value "C:\Users\DRS\SkyDriv..." to type Function". [Here I omitted the remainder of the query that deals with all the editing.]

let
//Source = Csv.Document(File.Contents("C:\Users\DRS\SkyDrive\DRS_JRS\Investments\JRS_StockData\UntitledWatchList-stocksAndEtfs.csv"),[Delimiter=",",Encoding=1252]),
myPath=ParametersStocks("DataStocks"),
Source = Excel.Workbook(File.Contents(myPath&"\UntitledWatchList-stocksAndEtfs.csv"), [Delimiter=",",Encoding=1252]),
#"Promoted Headers" = Table.PromoteHeaders(Source),
 
Last edited:
Upvote 0
Looks alright from here apart one thing: You still have to open your source as a Csv.Document instead of an Excel.Workbook.

So this is how you would call the function instead:

Source = Csv.Document(File.Contents(myPath&"\UntitledWatchList-stocksAndEtfs.csv"), [Delimiter=",",Encoding=1252]),
 
Upvote 0
Thanks again ImkeF. I altered the query to reflect that change to Csv but I get the same error. When I click on the gear symbol beside myPath in the Applied Steps area it tells me:

Error Message:


Value cannot be null.
Parameter name: source
 
Upvote 0
ImkeF, I figured it out but smashing around in the Query Editor. Either I misread Allington's blog or it wasn't clear.

I wasn't supposed to invoke the function by passing a parameter through it; I was supposed to let the query pass the parameter through the function! So I Close&Loaded the function ParametersStocks without invoking. Now everything seems in order.

See? Even a blind squirrel finds an acorn every once in a while.
 
Last edited:
Upvote 0
ImkeF, I figured it out but smashing around in the Query Editor. Either I misread Allington's blog or it wasn't clear.

I let Arlington know about this and he altered his blog posting to clarify the need to leave the function un-invoked.
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,786
Members
449,259
Latest member
rehanahmadawan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top