powerquery

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

独自空忆成欢 提交于 2019-12-01 22:40:33
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? You can use ActiveWorkbook.Queries.Item to get the query you want and use the Formula property to update the query's formula, like so: ActiveWorkbook.Queries.Item("LATEST").Formula = "let

Select row with MAX value per category Power BI

女生的网名这么多〃 提交于 2019-12-01 21:34:35
How to select row with max value per category in M of Power BI. Suppose we have table: +----------+-------+------------+ | Category | Value | Date | +----------+-------+------------+ | apples | 1 | 2018-07-01 | | apples | 2 | 2018-07-02 | | apples | 3 | 2018-07-03 | | bananas | 7 | 2018-07-04 | | bananas | 8 | 2018-07-05 | | bananas | 9 | 2018-07-06 | +----------+-------+------------+ Desired results are: +----------+-------+------------+ | Category | Value | Date | +----------+-------+------------+ | apples | 3 | 2018-07-03 | | bananas | 9 | 2018-07-06 | +----------+-------+------------+ Here

How to POST a multipart/form-data using Power Query's Web.Contents

浪子不回头ぞ 提交于 2019-12-01 10:54:09
In Power Query, I can download data from Web using the Web.Contents function, but there's an api that required the request to contains multipart/form data in the following format "__rdxml"=<*Some data*> So how do you do this using the Web.Contents function? I tried, doing ... PostContent = "__rdxml=<*Some data*>", Source Web.Contents(url,Content=Text.ToBinary(PostContent)) ... But server response with 400 Bad Request . I checked the raw request with Fiddler, it seem like the request is not sending with content-type=multipart/form-data header. I tried manually adding the content-type header

Dynamically expand ALL lists and records from json

我的梦境 提交于 2019-12-01 08:57:30
问题 I want to expand all lists and records in a json response. Columns are like e.g. (this is dynamically, it also can be 10 records and 5 lists): Text, Text, [List], [List], Text, [Record], [Record], String, [Record] I wrote a function for getting all columns with the specific type Cn.GetAllColumnsWithType = (table as table, typ as type) as list => let ColumnNames = Table.ColumnNames(table), ColumnsOfType = List.Select(ColumnNames, (name) => List.AllTrue(List.Transform(Table.Column(table, name),

How to POST a multipart/form-data using Power Query's Web.Contents

二次信任 提交于 2019-12-01 07:54:25
问题 In Power Query, I can download data from Web using the Web.Contents function, but there's an api that required the request to contains multipart/form data in the following format "__rdxml"=<*Some data*> So how do you do this using the Web.Contents function? I tried, doing ... PostContent = "__rdxml=<*Some data*>", Source Web.Contents(url,Content=Text.ToBinary(PostContent)) ... But server response with 400 Bad Request . I checked the raw request with Fiddler, it seem like the request is not

How can I turn the deepest elements of nested JSON payload into individual rows in Power Query?

≯℡__Kan透↙ 提交于 2019-11-30 23:47:05
Goal : I have a JSON payload with the following format: { "Values": [ { "Details": { "14342": { "2016-06-07T00:00:00": { "Value": 99.62, "Count": 7186 }, "2016-06-08T00:00:00": { "Value": 99.73, "Count": 7492 } }, "14362": { "2016-06-07T00:00:00": { "Value": 97.55, "Count": 1879 }, "2016-06-08T00:00:00": { "Value": 92.68, "Count": 355 } } }, "Key": "query5570027", "Total": 0.0 }, { "Details": { "14342": { "2016-06-07T00:00:00": { "Value": 0.0, "Count": 1018 }, "2016-06-08T00:00:00": { "Value": 0.0, "Count": 1227 } } }, "Key": "query4004194", "Total": 0.0 } ], "LatencyInMinute": 0.0 } I want to

How to achieve running total with power query?

六月ゝ 毕业季﹏ 提交于 2019-11-30 18:52:13
问题 I want to do a running total with power query like I did with Tableau software before. Does anyone have ideas, thanks in advance! 回答1: Apologies for the very late answer - this challenge has been nagging at me for many months. There are few solutions floating around forums and blogs but they all seem to need pages of custom M code. Some also cant meet the common requirement of needing to restart the running total when a group changes. So I came up a with a technique you can build without

How can I get a column value from previous row in Power Query?

本小妞迷上赌 提交于 2019-11-30 17:07:31
I want to get a value from the previous row. I tried the following code as suggested in this post : Table.AddColumn(#"Added index", "custom column", each {[Index]-1}[column name]) But it throws this error: Cannot use field access fot type List Please help, what am I doing wrong? The error comes because {[Index]-1} without anything before it is a list value, but instead you want to index into a row of a table with this syntax: MyTable{index} That looks like: = Table.AddColumn(#"Added index", "custom column", each #"Added index"{[Index]-1}[My Column]) 来源: https://stackoverflow.com/questions

WAAD Authentication with WebAPI OData service consumed by Excel PowerQuery

混江龙づ霸主 提交于 2019-11-30 15:57:48
问题 I've created a WebAPI OData 3.0 web service with an OWIN middleware, which is configured for authentication with Windows Azure Active Directory. The ODataControllers are marked with an [Authorize] attribute, and the IAppBuilder is configured as follows: app.UseWindowsAzureActiveDirectoryBearerAuthentication( new WindowsAzureActiveDirectoryBearerAuthenticationOptions { Tenant = ConfigurationManager.AppSettings["ida:Tenant"], TokenValidationParameters = new TokenValidationParameters {

WAAD Authentication with WebAPI OData service consumed by Excel PowerQuery

谁都会走 提交于 2019-11-30 15:38:29
I've created a WebAPI OData 3.0 web service with an OWIN middleware, which is configured for authentication with Windows Azure Active Directory. The ODataControllers are marked with an [Authorize] attribute, and the IAppBuilder is configured as follows: app.UseWindowsAzureActiveDirectoryBearerAuthentication( new WindowsAzureActiveDirectoryBearerAuthenticationOptions { Tenant = ConfigurationManager.AppSettings["ida:Tenant"], TokenValidationParameters = new TokenValidationParameters { ValidAudience = ConfigurationManager.AppSettings["ida:Audience"] }, }); ida:Tenant is my Windows Azure tenancy,