powerquery

How to split JSON columns in Power BI

元气小坏坏 提交于 2019-12-11 07:28:00
问题 I have imported JSON data from Hive database. The structure looks like the attached. JSON data has been dumped to Hive without normalizing. Is it possible to parse the data?. For example, in the attached image, the mentionedlocations column has some places mentioned and I want them to be in separate rows. 回答1: You can use the Json.Document function to read the column as JSON. I'd suggest creating a custom column with this formula: Record.ToTable(Json.Document([mentionedlocations])) and then

Power query recursive function: add more steps after the recursive step

♀尐吖头ヾ 提交于 2019-12-11 04:35:01
问题 Background: I have posted a question regarding a custom function in Power Query that I found in a blog by Chris Webb which I have already got an answer to.But now I have another question related to the same custom function. One of the amazing steps in that custom function is the recursive step at the end named " OutputTable " which calls itself using a if statement, basically making it a loop . Below is the step: OutputTable = if NextColumnNumber>(Table.ColumnCount(ExpandedTable)-1) then

Automatically Expand all “Table Columns” with specific name

坚强是说给别人听的谎言 提交于 2019-12-11 02:52:09
问题 I'm a beginner in coding and am not familiar with "M" modeling language. I have an XML file that I want to use to load the data in Query Editor. In the Query, I need to expand only the table columns with a specific name below: view viewfolder Attribute:name I have found the following post where they give a function by Chris Webb for expanding all the lists(below code). = (TableToExpand as table, optional ColumnNumber as number) => let ActualColumnNumber = if (ColumnNumber=null) then 0 else

Powerquery: Expand all columns of that have records in them

好久不见. 提交于 2019-12-11 02:36:03
问题 Using Power Query in Microsoft Excel 2013, I created a table that looks like this: // To insert this in Power Query, append a '=' before the 'Table.FromRows' Table.FromRows( { {"0", "Tom", "null", "null"}, {"1", "Bob", [ name="Berlin" , street="BarStreet" ], [ name="Mary", age=25 ]}, {"2", "Jim", [ name="Hamburg", street="FooStreet" ], [ name="Marta", age=30 ]} }, {"ID", "Name", "Address", "Wife"} ) Now, I want to expand the columns Address and Wife by using the name attribute on both records

How to refresh report that uses custom functions on Power BI Service?

懵懂的女人 提交于 2019-12-11 02:26:37
问题 I know this issue has been posted many times before, but I was not able to get a solid/working solution. I am trying to figure out a workaround for refreshing dataset with Custom functions over Power BI service. My query looks like the following: let Clients = Json.Document(Web.Contents("https://api.createsend.com/api/v3.2/clients.json")), #"Converted to Table" = Table.FromList(Clients, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Expanded Column1" = Table.ExpandRecordColumn(#

Is there a simple way to count occurences of one text string within another text string?

大憨熊 提交于 2019-12-10 19:21:27
问题 Is there a simple way, using PowerQuery, to count the occurences of a text string within another text string? For instance, if I have the string, "The quick brown fox jumps over the lazy dog and the lazy dog doesn't notice," how would I easily determine that the words lazy and dog occur twice? I know I can use Text.Contains to determine whether lazy and dog occur within the string, but I don't know a simple way to determine how many times they occur. 回答1: You can split the text, using the

Relative path for Folder.Files

試著忘記壹切 提交于 2019-12-10 18:45:55
问题 I have an Excel file, and in the same folder I have a folder with CSV files I want to include. Using the From Folder query thing, the first step will give the following query: = Folder.Files("D:\OneDrive\Documents\Health\Concept2") Now, this path will not be the same on my laptop for example, but the Excel file will always be in the Health directory... I get an error if I try to just pass a relative path to Folder.Files , but is there a way to work around this? A fancy function? Some variable

How to refer columns in Power Query by index or position?

孤街醉人 提交于 2019-12-10 18:28:46
问题 I have a line as below in Power Query. So instead of referring it by name, I want it by position dynamically. Can someone help here, please #"Filtered Part Desc" = Table.SelectRows(#"Removed Columns3", each Text.Contains([part_desc], "ENG") or Text.Contains([part_desc], "TRANS")) I tried replacing [part_desc] by Table.ColumnNames(Promoted){6} , but it is not working 回答1: You can use Table.ColumnNames(MyTable){n} to return a column name by its position - this this is base 0, so the 6th column

Find String from One List within Another List and Return String Found

牧云@^-^@ 提交于 2019-12-10 18:14:59
问题 I found part of what I was looking for at Matchlists/tables in power query, but I need a bit more. Using the "Flags only" example provided at Matchlists/tables in power query, I’m comparing two lists, ListA and ListB, to check if ListB’s row content appears in ListA’s row content at all. I can’t do a one-for-one match of both rows’ contents (like with List.Intersect) because the content of a row in ListB might only be part of the content of a row in ListA . Note that, in the query below,

Power Query Looping

只谈情不闲聊 提交于 2019-12-10 10:35:56
问题 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