powerquery

Power Query - Select Columns from table instead of removing afterwards

无人久伴 提交于 2019-12-06 14:47:53
问题 The default behaviour when importing data from a database table (such as SQL Server) is to bring in all columns and then select which columns you would like to remove. Is there a way to do the reverse? ie Select which columns you want from a table? Preferably without using a Native SQL solution. M: let db = Sql.Databases("sqlserver.database.url"){[Name="DatabaseName"]}[Data], Sales_vDimCustomer = db{[Schema="Sales",Item="vDimCustomer"]}[Data], remove_columns = Table.RemoveColumns(Sales

Power Query Looping

戏子无情 提交于 2019-12-06 09:30:31
I used Power Query to pull all of the unique Item Types tested in the past month: let Source = Sql.Database("XXX", "YYY"), dbo_tblTest = Source{[Schema="dbo",Item="tblTest"]}[Data], #"Filtered Rows" = Table.SelectRows(dbo_tblTest, each Date.IsInPreviousNMonths([Test_Stop], 1)), #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each Text.Start([Item],5)), #"Removed Duplicates" = Table.Distinct(#"Added Custom", {"Custom"}) in #"Removed Duplicates" To get: Test_ID --- Item --- Test_Start --- Test_Stop --- Custom 2585048 --- B1846-6-02 --- 1/14/2014 12:46 --- 6/25/2015 14:28 --- B1846

powerquery split column by variable field lengths

泄露秘密 提交于 2019-12-06 00:50:47
In PowerQuery I need to import a fixed width txt file (each line is the concatenation of a number of fields, each field has a fixed specific length). When I import it I get a table with one single column that contains the txt lines, e.g. in the following format: AAAABBCCCCCDDD I want to add more columns in this way: Column1: AAAA Column2: BB Column3: CCCCC Column4: DDD In other words the fields composing the source column are of known length, but this length is not the same for all fields (in the example above the lengths are: 4,2,5,3). I'd like to use the "Split Column">"By number of

How to search multiple strings in a string?

偶尔善良 提交于 2019-12-05 07:05:29
I want to check in a powerquery new column if a string like "This is a test string" contains any of the strings list items {"dog","string","bark"} . I already tried Text.PositionOfAny("This is a test string",{"dog","string","bark"}) , but the function only accepts single-character values Expression.Error: The value isn't a single-character string. Any solution for this? This is a case where you'll want to combine a few M library functions together. You'll want to use Text.Contains many times against a list, which is a good case for List.Transform . List.AnyTrue will tell you if any string

Power Query - Select Columns from table instead of removing afterwards

牧云@^-^@ 提交于 2019-12-04 19:46:09
The default behaviour when importing data from a database table (such as SQL Server) is to bring in all columns and then select which columns you would like to remove. Is there a way to do the reverse? ie Select which columns you want from a table? Preferably without using a Native SQL solution. M: let db = Sql.Databases("sqlserver.database.url"){[Name="DatabaseName"]}[Data], Sales_vDimCustomer = db{[Schema="Sales",Item="vDimCustomer"]}[Data], remove_columns = Table.RemoveColumns(Sales_vDimCustomer,{"Key", "Code","Column1","Column2","Column3","Column4","Column5","Column6","Column7","Column8",

Overcome the export limit of 150k rows from Power BI

前提是你 提交于 2019-12-04 18:24:58
Is there a way to overcome Power BI export limit of max 150k rows? Limit docs: https://docs.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-export-data#limitations-and-considerations Voting for PBI improvement: https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/18432742-increase-export-data-limits Ok, I got through with that. It is possible. You should be familiar with R and SQL Server to do that. The example below exports 201k rows directly form PBI to SQL Server. Install RODBC package in R. For those who want to do that from scratch, please check the reference

How to automate a power query in VBA?

我的梦境 提交于 2019-12-04 18:17:39
问题 I have data in sheet 1. Normally I go to power query and do my transformations, then close, and load to an existing sheet 2. I would like to automate this using VBA, where I can just run my power query automatically and populate the transformation to sheet 2. Macro recorder doesn't seem to allow me to record the steps. And there isn't much online about doing this. Trying some simpler code: Sub LoadToWorksheetOnly() 'Sub LoadToWorksheetOnly(query As WorkbookQuery, currentSheet As Worksheet) '

Excel 2013 power query - SQL query with a dynamic parameter

筅森魡賤 提交于 2019-12-04 16:42:26
however I have looked from the web I cant find a simple(!) example that would show how to use and have a SQL query that would use in the WHERE a dynamic parameter value. What I'm looking for is that the end user would be able to change a value in the column in the spreadsheet (ParameterTable?) and refresh the data using this new value as a parameter. Perhaps an example describes best what I'm after. I would have a table in excel that would have two columns, named ParameterName and ParameterValue. These would then have values PARM1 and 1 (Sorry but appears that I cant post an image here) The

authenticating with Excel Power Query against .Net Odata Web Api

此生再无相见时 提交于 2019-12-04 14:22:01
I am trying to use Power Query to download an Odata Feed that I created using .net Web Api 2 and the OData v4 nuget package. I'm trying to access an Odata feed that requires authentication. When I edit the authentication type in power query, I'm never seeing the authentication key come through in the request. How do you configure Power Query to use a specific type of authentication? Bonus: I'm using OAuth, so how would I configure power query to send in a header with auth data that includes "Authorization Bearer:token_here" Web API credentials are for putting a secret value into to the URL

Power Query: transform a column by multiplying by another column

我的未来我决定 提交于 2019-12-04 03:52:54
问题 I want to do something similar to Power Query Transform a Column based on Another Column, but I'm getting stuck on how to modify the syntax for my particular goal. Similar to the linked question, assume that I have the following table: Table 1: Column A | Column B | Column C ------------------------------ 1 | 4 | 7 2 | 5 | 8 3 | 6 | 9 Instead of changing the value of the Column A conditional on Column B, I want to multiply the values in multiple columns (Column B and Column C) by those in