powerquery

How do I comment in Power Query M?

一世执手 提交于 2019-12-03 22:03:30
Is there a way to comment M code / comment out lines or blocks of code? Alejandro Lopez-Lago - MSFT M supports two different types of comments: Single line comments can be started with // You can comment out multiple lines or comment out text in the middle of a line using /* */ (e.g. = 1 + /* some comment */ 2 ) Comments might seem to disappear in the formula bar if they are at the end of the line, but they are still there. You can verify this by looking at your code in the Advanced Editor. 来源: https://stackoverflow.com/questions/31569679/how-do-i-comment-in-power-query-m

Add missing date rows in Power BI/Power Query and take value of row above

落爺英雄遲暮 提交于 2019-12-03 21:39:36
Say I am importing something like the following into PowerBI: Date | Quantity |---------------------|------------------| | 1/1/2018 | 22 | | 1/3/2018 | 30 | | 1/4/2018 | 10 | |---------------------|------------------| Where the external source table is a series of date, value rows with some date values missing. I'd like to execute some DAX/M to add any missing date rows into the data set, where 'Quantity' value is taken from the first date prior. So my resulting dataset would like like this: Date | Quantity |---------------------|------------------| | 1/1/2018 | 22 | | 1/2/2018 | 22 | | 1/3

What's the difference between DAX and Power Query (or M)?

非 Y 不嫁゛ 提交于 2019-12-03 04:13:51
问题 I have been working on Power BI for a while now and I often get confused when I browse through help topics of it. They often refer to the functions and formulas being used as DAX functions or Power Query, but I am unable to tell the difference between these two. Please guide me. 回答1: M and DAX are two completely different languages. M is used in Power Query (a.k.a. Get & Transform in Excel 2016) and the query tool for Power BI Desktop. Its functions and syntax are very different from Excel

What's the difference between DAX and Power Query (or M)?

吃可爱长大的小学妹 提交于 2019-12-02 17:30:34
I have been working on Power BI for a while now and I often get confused when I browse through help topics of it. They often refer to the functions and formulas being used as DAX functions or Power Query, but I am unable to tell the difference between these two. Please guide me. M and DAX are two completely different languages. M is used in Power Query (a.k.a. Get & Transform in Excel 2016) and the query tool for Power BI Desktop. Its functions and syntax are very different from Excel worksheet functions. M is a mashup query language used to query a multitude of data sources. It contains

Power Query - Data Transformation from a single column to a whole table

落爺英雄遲暮 提交于 2019-12-02 07:07:52
问题 I have a requirement where I have a table like this - Actual Table with 2 columns Column1 Column2 ColAValue $$ ColBValue $$ New Row ColCValue Above Row ColCValue2 Above Row $$ ColDValue Above Row ColAValue $$ ColBValue $$ ColCValue $$ ColDValue New Row ColAValue $$ ColBValue $$ ColCValue New Row $$ ColDValue Above Row I know by requirement, I would have 4 columns in my dataset leaving column 2 . I need my transformed table as a new table using query editor. This is my expected output,

Power Query - Data Transformation from a single column to a whole table

核能气质少年 提交于 2019-12-02 06:09:51
I have a requirement where I have a table like this - Actual Table with 2 columns Column1 Column2 ColAValue $$ ColBValue $$ New Row ColCValue Above Row ColCValue2 Above Row $$ ColDValue Above Row ColAValue $$ ColBValue $$ ColCValue $$ ColDValue New Row ColAValue $$ ColBValue $$ ColCValue New Row $$ ColDValue Above Row I know by requirement, I would have 4 columns in my dataset leaving column 2 . I need my transformed table as a new table using query editor. This is my expected output, OutTable with 4 columns Basically the column values are identified in order by delimiter $$ and if column2

replace multiple words in string with specific words from list

∥☆過路亽.° 提交于 2019-12-02 04:25:37
问题 How can I, using M-language, replace specific words in a string with other specific words that are specified in a table? See my example data: Source code: let someTable = Table.FromColumns({{"aa &bb &cc dd","&ee ff &gg hh &ii"}, {Table.FromColumns({{"&bb","&cc"}, {"ReplacementForbb", "ccReplacement"}},{"StringToFind", "ReplaceWith"}), Table.FromColumns({{"&ee", "&gg","&ii"}, {"OtherReplacementForee", "SomeReplacementForgg", "Replacingii"}},{"StringToFind", "ReplaceWith"})}, {"aa

Add column of previous values from table of tables in Power BI / Power Query

我的未来我决定 提交于 2019-12-02 04:23:44
Looking for a followup to Max Zelensky's solution here . Assuming the original example had a [Date] field, I'm trying to go one more level and add a column that shows the prior [Date] value I've also looked here and here and here . Per Max, I've created the table of tables: AddedCustom = Table.AddColumn(GroupedRows, "Custom", each Table.AddIndexColumn([tmp],"Occurrence", 1,1) type table) Created a second index: SecondIndex= Table.AddColumn(AddedCustom, "Custom.2", each Table.AddIndexColumn([Custom],"Occurance.2", 0,1), type table) I've successfully added a column that references the current

How to edit the source of a power query using VBA?

我的未来我决定 提交于 2019-12-02 02:11:01
问题 I am trying to edit the source of one of my queries using VBA. This is what I have so far: Dim mFormula As String mFormula = _ "let Source = Excel.Workbook(File.Contents(wbname), null, true) in Source" query1 = ActiveWorkbook.Queries.Add("LATEST", mFormula) I set wbname previously in my code. "LATEST" is already added, instead of delete it and read it, I would just like to change the source. Is this possible? 回答1: You can use ActiveWorkbook.Queries.Item to get the query you want and use the

Power Query, make http POST request with form data

一笑奈何 提交于 2019-12-02 01:25:53
问题 I have a REST API, which accepts only POST requests with form data. I know that in Power Query JSON requests are like this: let url = "https://example.com", body = "{ ""first_param"": ""AAAAA"", ""second_param"": ""BBBBBB""}", Source = Json.Document(Web.Contents(url,[ Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] )) in Source How it is possible to send form data?? 回答1: Use Uri.BuildQueryString and Json.Document let url = "https://example.com", body = "{ "