Quantcast
Channel: Power Query topics
Viewing all 31238 articles
Browse latest View live

OLE DB or ODBC error: Type mismatch.

$
0
0

Hello

 

I use the following to insert an empty row in a table regardless of the columns it may have:

 

= Table.InsertRows(#"Replaced Value", 0,{Record.FromList(List.Repeat({""},Table.ColumnCount(#"Replaced Value")),Table.ColumnNames(#"Replaced Value"))})

 

However, I get the error:

OLE DB or ODBC error: Type mismatch.

 

Any idea how to fix that? 

 

Thanks


Sort columns contains weeks values

$
0
0

Hey guys,

 

I Have a list of unsorted weeks, here is an example:

 

02/08 - 08/08
06/09 - 12/09
09/08 - 15/08
13/09 - 19/09
16/08 - 22/08
23/08 - 29/08
26/07 - 01/08
30/08 - 05/09

 

I want to pivot the column to make the list the headers, and after that I want to sort them ascending by the dates.

 

How you will recommend to sort them? Thanks!

Null values causing error on Custom Column

$
0
0

Hi,

 

I have an Amount column that also have some null's.

 

I'm using this expression to create a new column:

 

= Table.AddColumn(#"Expanded Table", "Selected", each if [Amount USD] < 50000 and [Company] = "A" then "Yes" else if [Amount USD] is null and [Company] = "A" then "Yes" else "No")

The resulting column is giving me errors whenever there was a null of the Amount USD Column.

 

Appreciate your help,

 

Guillermo

custom column syntax

$
0
0

I have the below custom column in the query editor, where the source is a table with text data and then 2 columns are created upon this.
 
I need to change the source to the table 'rel' and the column 'Score'. No matter what youtube tutorials or format changes i try i keep getting errors.
 
Would some one be able to help amend the syntax to use the source table and column above where applicable?
 
let
  Source = #table(
      {"Column1"},
      List.Zip(
          {{
              "Call me on 08588812885",
              "Call me on 07525812845",
              "I need assitance please call me",
              "Last tried in 2019"
            }}
        )
    ),
  #"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Split([Column1], " ")),
  #"Added Custom1" = Table.AddColumn(
      #"Added Custom",
      "Custom.1",
      each Text.Combine(
          List.Select(
              [Custom],
              (l) => [
                        ListOfCharacters = Text.ToList(l),
                        Result = not (List.Count(ListOfCharacters) >= 10
                                    and List.AllTrue(
                                            List.Transform(ListOfCharacters, (x) => List.Contains({"0".."9"}, x))
                                    )
                    )][Result]
            ), " ")
    )
in
  #"Added Custom1"
 

How to apply a slicer from one table to another table

$
0
0

Hi there, I am new to Power BI and do need some help on how to link a slicer from TableA to TableB. Basically, the slicer is coming from Type column from TableA.  What I need is when the user select an option as FY1 or FY2, TableB will be filtered by matching their ID.  For example, when FY1 is selected, the TableB will be filtered as

1 10

1 20

2 30

2 10

Join TableA and TableB does not work, as ID are not unique is either A or B.

The goal to get the sum of 10,20,30,10 when FY1 is selected, or 5,5,20,10 when FY2 is selected.

 

Any help is greatly appreciated.

 

Capture.PNG

How to Parse and Extrat data from column using delimiter

$
0
0

Hi,

 

I have the following Input table(see pic below) and I'd like to have it in the format shown in Output table. How do I parse the column FruitsQuantity taking into account there can the N occurences(\Fruit\Quantity) per person.

Cami_0-1600094135590.png

 Thanks!

Error Table to list

$
0
0

Hi guys I am getiing an error as the only element in my list. Everything goes right untill the last step when i change it to list

AlekseiNexa_0-1600094972232.png

 

let
Origen = Excel.Workbook(Web.Contents("https://.....xlsx"), null, true),
filtro_Sheet = Origen{[Item="cuenta",Kind="Sheet"]}[Data],
#"Encabezados promovidos" = Table.PromoteHeaders(filtro_Sheet, [PromoteAllScalars=true]),
#"Tipo cambiado" = Table.TransformColumnTypes(#"Encabezados promovidos",{{"cuenta", Int64.Type}}),
#"Duplicados quitados" = Table.Distinct(#"Tipo cambiado"),
Personalizado1 = Table.ToList(#"Duplicados quitados")
in
Personalizado1

Extract 24 hour date/time ranges as additional rows

$
0
0

Good day,

 

I am encountering an issue which I cannot figure out by myself. Hopefully one of you can help me 😀

 

From an excel file, I extract tasks and their respective start- and end date/time columns (see example below). These can range from times within the same day, but also span multiple days. However, for each task I need to have the time span per day in which the task is “active” ranging from 00:00:00 until 23:59:59 (see example for better understanding).

 

TABLE1 (start situation)

TaskStart Date/TimeEnd Date/Time
114/09/2020 14:00:0014/09/2020 16:00:00
214/09/2020 14:00:0015/09/2020 16:00:00
314/09/2020 14:00:0018/09/2020 16:00:00

 

Table 1: (needed situation)

TaskStart Date/TimeEnd Date/Time
114/09/2020 14:00:0014/09/2020 16:00:00
214/09/2020 14:00:0014/09/2020 23:59:59
215/09/2020 00:00:0015/09/2020 16:00:00
314/09/2020 14:00:0014/09/2020 23:59:59
315/09/2020 00:00:0015/09/2020 23:59:59
316/09/2020 00:00:0016/09/2020 23:59:59
317/09/2020 00:00:0017/09/2020 23:59:59
318/09/2020 00:00:0018/09/2020 16:00:00

 

I currently do this with a function but it takes forever (i.e. hours) to load it like this and the loading window shows a much higher number of MBs than the size of the actual Excel file. In the end, I end up with a table of appr. 900K lines.

 

Thank you in advance!


Dataset not refreshing - The key didn't match any rows in the table

$
0
0

Hi all, 

I have searched this error and I see lots of solutions pointing to excel file names, but in my case I beleive my issue is on the D365 Business Central side. I have a report connected to D365 Business Central and I am getting this error all of a sudden. Could MS have done an update overnight to cause me the need to re-define the source? 

 

One evening I refreshed just fine, and then in the morning I went to refresh and got this error when I went in to the query builder this is the error I see...

 

baklost_0-1600123247671.png

 

 

Converting time value to a decimal number so it could be displayed as a value

$
0
0

Hey everyone,
So initally i had two time values, which was StartTime and EndTime and right now I got the duration between both as one column, but in the duration format. The problem is, I can't figure out how to make it as a decimal or whole number, so I could display it as a sum in histogram. The closest I got to this is take duration as total hours, however, I need precise time to be displayed in the histogram as a value. Any ideas? 

SQL Statement window became very small after the last few updates

$
0
0

Im not sure if it is just on my pc but Ive noticed the SQL window became uncharacterictically small to the point where looking at the query in there becomes impossible.

 

The whole window is not sizeable so I cant see a way to resize and make readeable. Is this a bug which needs fixing with a new update or is there a way for me to correct it.

 

DFC_0-1600162409448.png

 

PS:The window is from IBM Db2 database.

How List.PositionOF works

$
0
0

But this result seems strange only to me?

 

image.png

For the moment I do not exploit what does not fit me.
I would like to see if anyone else has the same impression as me.

 

Merging two tables with similar values

$
0
0

Hello,

 

I'm using Tabular 1400 for the data model.

 

I'm trying to merge two tables on values that do not 100% match. One table has a segment of the string from that other table I'm trying to merge.

I tried using fuzzy but we're talking over 100 million rows, not sure if it's the best for performance.

 

The goal is to normalize values in the main table by finding key substring within those values. I hope this makes sense.

Clean and Trim

$
0
0

Hi, I am trying to merge 2 inventory files using the item code. One of the queries has spaces after the item code, so I have both cleaned and trimmed the column. But it doesn't seem to make any difference - I end up with many item codes that are not found, and when I look at the final query, it is obvious that it  isn't working because the one inventory code has these spaces after it and that is affecting the merge.

 

But other than going to my source file, and removing the spaces there, which for obvious reasons I want to avoid, how do I get rid of these things?

VLOOKUP in power query

$
0
0
Hello,
in some of the last posts   

 

here

 

and

 

here

 

I've followed, the need to make comparisons between a text string and a pattern, as does the VLOOKUP function, has emerged.
So, I tried to sketch a function that would accomplish this comparison.
It was not easy for me to find a solution that was suitable for all the cases that came to mind from time to time and I am still not sure that it is very "robust".
I'd like to, if someone wants to try it out and point out situations where it doesn't do what it was meant for.

The specifications are these: simulate vlookup excel function:
which should translated to:
the pattern contains strings together with asterisks and the asterisks match any string (even empty).
If all the substrings of the pattern are in the same order in the sample string, the comparison is successful.
If the pattern starts or ends with a substring (not asterisk) the comparison is successful if the sample string begins and ends the same way.

 

 

 

 

 

 

let matchPatt = (schema, parola) => match(Text.Split(schema, "*"), parola), match = (pattern, word) => if List.Count(pattern) = 1 and (pattern{0} = "" or (List.Count(pattern) = 1 and pattern{0} <> "" and Text.StartsWith(Text.Reverse(word), Text.Reverse(pattern{0})) ) ) then "match" else if List.Count(pattern) = 1 and (pattern{0} <> "" and pattern{0} <> word) then "not match" else if Text.StartsWith(word, pattern{0}) then let tailPattern = List.Skip(pattern), tailWord = if (List.IsEmpty(tailPattern) or tailPattern{0} = "" or Text.PositionOf(word, tailPattern{0}) = - 1 ) then Text.Range(word, Text.Length(pattern{0})) else Text.Range( Text.Range(word, Text.Length(pattern{0})), Text.PositionOf(Text.Range(word, Text.Length(pattern{0})), tailPattern{0}) ) in(tailPattern, tailWord) else "not match" in matchPatt

 

 

 

 


Duration Format [hh]:mm

$
0
0

Hello Everyone

 

I have a file where we write down service durations we process for each customer. My goal is to sum up all durations for each customer and visualize these service durations with the format [hh]:mm. Works fine if I try this with Pivot, can't get it to work in Power Query / Power BI.

 

Example:

CustomerService Time
A80:20
B71:45
C53:30
D20:24
E05:59

 

Right now it shows these values in decimals, like this:

 

CustomerService Time
A3.35
B2.99
C2.23
D0.85
E0.25

 

Maybe someone has aaaa solution for this case?

 

Regards

Sandro

Pagination - UK COVID-19

$
0
0

I am trying to combine multiple pages from the UK coronavirus data link here for more information.  I have both a function and table setup to try and extract the data from the API query.  I am using the table to define which page each request should be refering to and the function to send the URL to the table for drilling down into the data. 

 

Code for function:

(params as text) =>
let
source = Web.Contents("https://api.coronavirus.data.gov.uk/v1/data?" & "filters=areaType=utla&structure={""areaType"":""areaType"",""areaName"":""areaName"",""areaCode"":""areaCode"",""date"":""date"",""newCasesBySpecimenDate"":""newCasesBySpecimenDate"",""cumCasesBySpecimenDate"":""cumCasesBySpecimenDate""}&format=json&page=" & params)
in
source

 

Code for table:

let
Source = Json.Document(Web.Contents("https://api.coronavirus.data.gov.uk/v1/data?" & "filters=areaType=utla&structure={""areaType"":""areaType"",""areaName"":""areaName"",""areaCode"":""areaCode"",""date"":""date"",""newCasesBySpecimenDate"":""newCasesBySpecimenDate"",""cumCasesBySpecimenDate"":""cumCasesBySpecimenDate""}&format=json")),
pagination = Source[pagination],
totpages = pagination[last],
newvalue = Replacer.ReplaceText(totpages, "/v1/data?filters=areaType=utla&structure=%7B%22areaType%22:%22areaType%22,%22areaName%22:%22areaName%22,%22areaCode%22:%22areaCode%22,%22date%22:%22date%22,%22newCasesBySpecimenDate%22:%22newCasesBySpecimenDate%22,%22cumCasesBySpecimenDate%22:%22cumCasesBySpecimenDate%22%7D&format=json&page=", ""),
newvalue2 = Number.FromText(newvalue),
List = {1..newvalue2},
#"Converted to Table" = Table.FromList(List, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "List"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"List", type text}}),
#"Invoked Custom Function" = Table.AddColumn(#"Changed Type", "Function", each Function([List])),
Function1 = #"Invoked Custom Function"{0}[Function], //this is where I think the issue is as this will only show the first page
#"Imported JSON" = Json.Document(Function1,65001),
data = #"Imported JSON"[data],
#"Converted to Table1" = Table.FromList(data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"areaType", "areaName", "areaCode", "date", "newCasesBySpecimenDate", "cumCasesBySpecimenDate"}, {"Column1.areaType", "Column1.areaName", "Column1.areaCode", "Column1.date", "Column1.newCasesBySpecimenDate", "Column1.cumCasesBySpecimenDate"})
in
#"Expanded Column1"

 

The issue I am having is that only the first record (page 1) is showing in the output that I require and I want to extract all into one table! 

 

Any help would be amazing!

 

Anthony

Duplicate continents in filled map.

$
0
0

Hi All,

 

I am facing an isssue with the filled map.

As, I am adding countries to the map it is showing duplicate contnents.

Attaching Screenshot for the following:

Map.PNG

 

As, you can see Asia is coming twice.

Can you please help me out with this.

 

Thanks.

keepind dates as column headers

$
0
0

Hi,

 

I have date in excel where my dates aare my column headers- ed, Apr-20, MAy-20, etc. Now when I import my data in Power BI the headers are changed to text. But I need them to stay in date format as I need to show the change of month over month .

 

Pls help!

sgs_0-1600181609532.png

 

Issue fetching paginated data from a REST API

$
0
0

Dear all,

i'm currently confronted with a pagination issue when getting data from a REST Apo.

 

When querying the REST API with a custom query i get the total of pages in return, but the query is repeating the data from the first page, and it doesn't return fetch the data from the others pages.

 

The custom query im using

 

let
BaseUrl = "--",
Token = "--",
EntitiesPerPage = 50,

GetJson = (Url) =>
let
Options = [Headers=[access_token="--", Accept="--", #"Content-Type"="--"]],
RawData = Web.Contents(BaseUrl, Options),
Json = Json.Document(RawData)
in Json,

GetEntityCount = () =>
let Url = BaseUrl & "$count=true&$top=0",
Json = GetJson(Url),
Count = Json[#"count"]
in Count,
GetPage = (Index) =>
let Skip = "$offset=" & Text.From(Index * EntitiesPerPage),
Url = BaseUrl & Skip,
Json = GetJson(Url),
Value = Json[#"items"]
in Value,

EntityCount = List.Max({ EntitiesPerPage, GetEntityCount() }),
PageCount = Number.RoundUp(EntityCount / EntitiesPerPage),
PageIndices = { 0 .. PageCount - 1 },
Pages = List.Transform(PageIndices, each GetPage(_)),
#"Converted to Table" = Table.FromList(Pages, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandListColumn(#"Converted to Table", "Column1"),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1", {"href", "id", "firstName", "lastName"}, {"Column1.href", "Column1.id", "Column1.firstName"})
in
#"Expanded Column2"

 

I'm a newbie in Power Query so kindly ask your support & suggestions on how to resolve this issue.

 

 

Viewing all 31238 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>