m

Arranging Data in a Query Table

喜欢而已 提交于 2019-12-12 01:49:14
问题 I'm trying to figure out a simple way (using PowerQuery) to convert this: into this: I've spent days trying to figure out a simple way to do it. Everything I've tried has failed. 回答1: You can use Group By on the Transform tab, group by project and define a aggregation for each of the segment columns (e.g. Sum). Then adjust the created code from List.Sum to List.RemoveNulls. Then add a column with nested tables from the segment columns, using Table.FromColumns. Remove the original segment

Add a running total to a PowerQuery result

邮差的信 提交于 2019-12-11 16:42:54
问题 I am trying to create a count of dates that occur during particular weeks (the last five weeks including this week) and a total running count for dates which would include records prior to the listed five week duration. I could do this fairly easily using standard Excel formula, but I'm trying to learn PowerQuery and the M language. My first query returns the relevant rows from the original source data (another query that pulls everything from the Excel table and forces the correct data type

Power Query - Add Column CountIF across two tables ie =COUNTIF(People[CityId],[@Id])

烂漫一生 提交于 2019-12-11 14:24:16
问题 I have two tables in PowerQuery City and People . CITY Id, Name 1, Brisbane 2, Sydney 3, Melbourne PEOPLE Id, Name, CityId 1, Jay, 1 2, Sam, 2 3, Paul, 1 4, Sarah, 3 I'd like to add a column to City that shows a count of how many people belong to that city. So far I have: Table.AddColumn(City, "People.Count", each Table.RowCount( Table.SelectRows( People, each [CityId] = [Id] ) ) ) This returns all zeros in the new column. If I replace [Id] with 1 then I get 2 . It appears the [] references

Interactive Dialog Box in PowerBI

痞子三分冷 提交于 2019-12-11 13:23:09
问题 Is there a way to create an interactive Dialog box in PowerBI? I have R script embedded into the query editor, and I would like to have an interactive aspect to where I can use: file<-winDialogString("File input?","") This input would be used as the file location for a read csv and everytime someone opens and executes the Master copy of the PowerBI file, they can input a new file location. I am also open to html, javascript, python... anything that could help. 回答1: The best way to achieve

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

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

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,