powerquery

SUM IF in Power BI

≯℡__Kan透↙ 提交于 2019-12-10 10:06:23
问题 Is it possible to SUM on conditions in Power BI? I have a column that contains the values UK and Italy alongside other columns: employee and hours spent. I want to make a measure to show total hours spent by an employee in Italy and another to show total hours spent by an employee in UK. I am having no luck with the DAX language. Can anyone help? 回答1: Yes. There are two basic approaches to this. CALCULATE(SUM(TableName[Hours]), TableName[Country] = "Italy") or SUMX(FILTER(TableName, TableName

Power BI (Power Query) Web request results in “CR must be followed by LF” Error

六月ゝ 毕业季﹏ 提交于 2019-12-10 06:10:18
问题 When you use the Web.Page(Web.Contents('url')) function to read a table from a web page, some sites will cause an error due to inconsistent linefeeds. DataSource.Error: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF There doesn't appear to be any option you can pass to the Web functions to ignore those errors. This method works for a short while, but doesn't survive a save/refresh: let BufferedBinary = Binary.Buffer(Web.Contents("http://vote

Excel 2013 power query - SQL query with a dynamic parameter

天大地大妈咪最大 提交于 2019-12-09 20:29:49
问题 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

Cumulating row data over last 12 months in powerquery

∥☆過路亽.° 提交于 2019-12-08 23:11:32
I am creating a dashboard using Excel Powerquery(aka. M), in which I need to create a measure which requires rolling up values for last 12 months for two dimension Example: Input: D1 | D2 | MonthYear(D3) | Value A1 B1 Mar2016 1 A2 B1 Mar2016 2 A3 B1 Mar2016 3 A1 B1 Apr2016 4 A2 B1 Apr2016 5 A3 B1 Apr2016 6 A1 B1 May2016 7 A2 B1 May2016 8 A3 B1 May2016 9 Output: D1 | D2 | MonthYear(D3) | Value A1 B1 Mar2016 1 A2 B1 Mar2016 2 A3 B1 Mar2016 3 A1 B1 Apr2016 4+1 A2 B1 Apr2016 5+2 A3 B1 Apr2016 6+3 A1 B1 May2016 7+4+1 A2 B1 May2016 8+5+2 A3 B1 May2016 9+6+3 Also sum should be done only for last 12

How to remove duplicates from single Power Query column without removing entries rows?

南笙酒味 提交于 2019-12-08 13:29:06
问题 I have a merged query that I need to remove duplicates for my Invoice+Tax column without removing the entire row for that duplicate. I just need to remove the duplicate values for that one column. As you can see from the below picture I am trying to remove duplicate values from the Invoice+Tax column. But I need to keep the row, just remove the duplicate values, for example I have highlighted below what should be removed, anything not highlighted needs to remain. I have also included my code

Assign a number of occurrence to each record (sort of Count if)

*爱你&永不变心* 提交于 2019-12-08 11:52:49
问题 How can I achieve the same calculation in Power Query? In Excel I would use: =COUNTIF($A$2:A2,A2) Name Occurrence A 1 A 2 B 1 A 3 B 2 Thanks, Tamir 回答1: This could be reached via "buttons" only (almost - except some custom column formula): AddedIndex = Table.AddIndexColumn(Source, "Index", 0, 1), GroupedRows = Table.Group(AddedIndex, {"Name"}, {{"tmp", each _, type table}}), AddedCustom = Table.AddColumn(GroupedRows, "Custom", each Table.AddIndexColumn([tmp],"Occurrence", 1,1)),

Moving one column to the end of another

萝らか妹 提交于 2019-12-08 10:39:59
问题 I have a bunch of excel files that are formatted in a pretty weird way that I would like to make an automated import script for, so I can easily get this data into a sheet with the correct formatting. It has hourly values for each month in the first 12 columns, then the date along with hours in the next 12 columns. What I would like to do is be able to get this data in to a table where the first column has the date and hour (in excel format) and the second one containing the data. My thought

Load *.htm file saved as .xls (starting from row number 5) Using Power Query

瘦欲@ 提交于 2019-12-08 06:13:21
问题 I have to import an .xls file which is saved as .*htm, .*html. I attached a link which provides a sample file of that format. The Actual first row of the table starts from row number 5. But there are data above it. The file looks as below, The sample file. But please make sure to include some rows on top of it with some test values and make it look like the screenshot above. if there are no rows above it, then the following M Code provided by Alexis Olson works let Source = Folder.Files("C:

How can I perform the equivalent of AddHours to a DateTime in Power Query?

元气小坏坏 提交于 2019-12-07 15:02:06
问题 I've seen PowerQuery expressions that can subtract days from a datetime, like DateTimeZone.UtcNow.AddDays(-1). However, I'd like to subtract hours from a DateTime, not days. As I don't see a function like AddHours() in the Power Query specification, is there a robust way to go back a number of hours? For instance, would something like DateTimeZone.UtcNow + #duration(0, -1, 0, 0) give me a DateTime that's one hour earlier? [Note: I'd try this myself but I can't get Power Query installed on my

Load *.htm file saved as .xls (starting from row number 5) Using Power Query

别等时光非礼了梦想. 提交于 2019-12-06 18:17:25
I have to import an .xls file which is saved as .*htm, .*html. I attached a link which provides a sample file of that format. The Actual first row of the table starts from row number 5. But there are data above it. The file looks as below, The sample file . But please make sure to include some rows on top of it with some test values and make it look like the screenshot above. if there are no rows above it, then the following M Code provided by Alexis Olson works let Source = Folder.Files("C:\Users\aolson\Downloads\example-html.xls"), #"Filtered Rows" = Table.SelectRows(Source, each ([Extension