Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I'm trying to use the PowerQuery Beta for some SSIS packages. I was curious if any one had used this, in particular the ability to set a PowerQuery equivalent to a variable. I've "gotten" it to work if I use the simple method of declaring the full PowerQuery statement in the "Single Query Text" box. However I'm unable to save a PowerQuery Statement to a string variable. It get an evaluation error message.
Here's the query (just testing at this point)
let
BaseDate = DateTime.LocalNow(),
WeekStart = Date.AddDays(Date.StartOfWeek(BaseDate,1),7),
PeriodList = List.Dates(DateTime.Date(WeekStart),Number.FromText("5"),#duration(Number.FromText("6")+1,0,0,0)),
StartDates = Table.FromList(PeriodList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
EndDates = Table.AddColumn(StartDates,"EndDate",each Date.AddDays([Column1],Number.FromText("6")))
in
EndDates
I get this error message when trying to save the Variable. I'm guessing I need to wrap the statement in something, but I don't know what that is.
TITLE: Expression Builder
------------------------------
Expression cannot be evaluated.
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%C2%AE%20Visual%20Studio%C2%AE&ProdVer=16.6.30204.135&Evtsrc=Microsoft.DataTransformationServices.Controls.TaskUIFramework.TaskUIFrameworkSR&EvtID=FailToEvaluateExpression&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
Attempt to parse the expression "let
BaseDate = DateTime.LocalNow(),
WeekStart = Date.AddDays(Date.StartOfWeek(BaseDate,1),7),
PeriodList = List.Dates(DateTime.Date(WeekStart),Number.FromText("5"),#duration(Number.FromText("6")+1,0,0,0)),
StartDates = Table.FromList(PeriodList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
EndDates = Table.AddColumn(StartDates,"EndDate",each Date.AddDays([Column1],Number.FromText("6")))
in
EndDates" failed. The expression might contain an invalid token, an incomplete token, or an invalid element. It might not be well-formed, or might be missing part of a required element such as a parenthesis.
(Microsoft.DataTransformationServices.Controls)
The official page has nothing to help
Hi Thanks for this I am struggeling with the same. I am trying to use a Bearer Token as a parameter for a web source. How should I implement the @[User::Bearer] variable in this query?
Source = Json.Document(Web.Contents("https://api.sam360.com/api/Report/GetRecords?reportId=HardwareAllComputersGeneralDetails&organisatio...", [Headers=[Authorization= @[User::Bearer] , "Content-Type"="application/json; charset=utf-8"]])),
Based on my recent experience I think you'd wind up with something similar to:
The SSIS variable declaration is going to need to be broken into two different strings and concatenated with your user variable.
The existing double quotes in Power Query, need to be escaped with a \.
"
Source = Json.Document(Web.Contents(\"https://api.sam360.com/api/Report/GetRecords?reportId=HardwareAllComputersGeneralDetails&organisatio...\", [Headers=[Authorization="+@[User::Bearer]+" , \"Content-Type\"=\"application/json; charset=utf-8\"]])),
....
"
I wound up coming back to this for a new project and believe I figured out what I needed to do to translate Power Query in Power BI to a SSIS variable. Mainly documenting this for my future self.
The main thing is that any " characters need to be escaped and if you're using a variable inline, the string needs to be broken and concatenated with the variable using a + .
Hope this is helpful to others.
Original PQ sample
let
Source = Folder.Files("C:\Users\me\Completed\"),
#"Filtered Rows" = Table.SelectRows(Source, each ([Extension] = ".xml")),
#"Filtered Hidden Files1" = Table.SelectRows(#"Filtered Rows", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
in
#"Renamed Columns1"
I used used Find & Replace in a text editor and then tweaked to include the variable I needed
"
let
Source = Folder.Files(\"" + @[User::MyVariable] + "\"),
#\"Filtered Rows\" = Table.SelectRows(Source, each ([Extension] = \".xml\")),
#\"Filtered Hidden Files1\" = Table.SelectRows(#\"Filtered Rows\", each [Attributes]?[Hidden]? <> true),
#\"Invoke Custom Function1\" = Table.AddColumn(#\"Filtered Hidden Files1\", \"Transform File\", each #\"Transform File\"([Content])),
#\"Renamed Columns1\" = Table.RenameColumns(#\"Invoke Custom Function1\", {\"Name\", \"Source.Name\"}),
in
#\"Renamed Columns1\"
"
Hi @jnickell ,
Here is a blog about "Power Query Source for SQL Server Integration Services" for your reference:
https://www.mssqltips.com/sqlservertip/6305/power-query-source-for-sql-server-integration-services/
It looks like this article takes the same approach as others. It requires a fully self contained power query statement. It doesn't reference using the Power Query from a Variable approach.
Sorry if there's a double post, the first one errored and it doesn't look like it saved it.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
71 | |
55 | |
43 | |
28 | |
22 |