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

Expression.Error: We cannot convert the value to type List

$
0
0

Hi all,

 

I have a collection of data that I am trying to adjust to break cumulative numbers down into specific period numbers. To this extent I've written the following code:

 

#"Specific Column" = Table.AddColumn(#"Changed Type4","Specific", each if [Column1]{[Index]-1} = [Column1]{[Index]-2} and [Column2]{[Index]-1} = [Column2]{[Index]-2} then [Amount]{[Index]-1} - [Amount]{[Index]-2} else [Amount]{[Index]-1})

 

The concept is that the column should compare both Columns 1 & 2 and if they both match, meaning they are part of the same data group, the Specific value should be the difference in amounts. If they don't match, meaning we're starting a new data group, then the Specific value is just the same as the current.

 

However, when I hit enter, the Specific column is filled with errors that say Expression.Error: We cannot convert the value "(text from Column1)" to type List.

 

Both Column1 and Column2 are type:text, and I have no idea why they would be converting the individual values to type List anyway. Can somebody help?

 

Thanks,

Jason


Add timecolumn to another timecolumn

$
0
0

I have a pbix file with 2 timecolumns coming from a CSV; 1 is a fixed value for the whole CSV (let's say 15:00:00) and the second column is chanching for every row (let's say; 00:00:01, 00:00:01, 00:00:01, 00:00:02, 00:00:02, 00:00:03, 00:00:03, 00:00:03, 00:00:03, 00:00:03......). Now I want to create a combined column which gives these output: 15:00:01, 15:00:01, 15:00:01, 15:00:02, 15:00:02, 15:00:03, 15:00:03, 15:00:03, 15:00:03, 15:00:03.

 

Can somebody give me a hint about what to do?

I've been trying so many things:

- using duration function (but couldn't get it done with a variable amount of seconds

- converting time to number

- converting time to text/string and stripping it and calculating the amount of hours, minutes and seconds

- adding a date to the first time to make it possible to use and so on

 

Everything is hard or gives problems. But I'm pretty sure it must be possible and not really hard. Somebody has a tip for me?

SQL Queries stall

$
0
0

Hi Folks,

 

I have a function that calls a simple sql query to get 1 row based on the value in a column.

 

"= ( somenumber as number )
=> let
numberasastring = Number.ToText(somenumber ),
Source = Sql.Database("server", "database", [Query="SELECT TOP 1 * FROM DB WHERE " & numberasastring  & "= thenumberinsql"])
in
    Source"

 

This is fairly slow (40 records per second or so, and the SQL Server is mostly idle the whole time) but it does work, however I seem to have issues where the queries just stop executing all together after loading for some time.

 

Ive connected SQL Profiler to powerbi desktop to try and see whats going on, but its just not doing anything.

 

Is there some other best practice for getting row level data from SQL for each row in a table in powerbi?

 

Append queries dynamically

$
0
0
Hi I have appended 4 different tables in one new table in query editor(power bi). The data source is Excel. But a user deleted a column in original data source in excel and now after refresh the appended new table is showing error. Is there a way in which even if user deletes a column in excel . The appended table or query should not be affected Thanks

Reformatting table/data structue

$
0
0

Hi,

 

I'm hoping someone can help. I have a table that contains survey results and I was wondering if there is some way I can format the data in the example below

 

tblSurveys

Customer     Question     Result

A                       1               Yes

A                       2

A                       3               www.test.com

B                       1               No

B                       2               Not Graded

B                       3               www.test2.com

C                       1               No

C                       2               Not Applicable

C                       3                www.test3.com

 

 

Re Formatted table

Customer     Q1              Q2                         Q3

A                   Yes                                           www.test.com

B                   No              Not Graded           www.test2.com

C                   No              Not Applicable      www.test3.com

 

API pay load to unique rows

$
0
0

Hi All, 

 

The goal: 

Have a single API and have multiple imputs that will trigger it providing diffrent data to each row.

 

I used the code below and it created a different column, I wanted that, however it gave me an error for each row. The variable will be "ID" and should be inputed to the API every diffrent row. 

*****************************************

= Table.AddColumn(#"Filtered Rows", "API pay load", each let


Source = each Json.Document(Web.Contents("https://dseapps.com//v1/reporting/investments?entity_type=portfolio&entity_id=" & [id] & "&report_date=2019-03-30&currency=Portfolio"
)),
Source1 = Source{0}
in
[API pay load])

***************************************

I was able to eliminitate the error and acrtually create a connection using the below code, however, it is requirin me to imput a paramater that I dont have or know... 

= Table.AddColumn(#"Filtered Rows", "API pay load", each let
Source = each Json.Document(Web.Contents("https://dseapps.com//v1/reporting/investments?entity_type=portfolio&entity_id="&[id]&"&report_date=2019-03-30&currency=Portfolio")), Source1 = Source{0},
Results = Table.FromRecords(Source),
#"Changed Type1" = Table.TransformColumnTypes(Results,{{"Investment ID", Int64.Type}, {"Portfolio Name", type text}, {"Investor Name", type text}, {"Fund Name", type text}, {"Closing Date", type date}, {"Liquidation Date", type date}, {"Active / Liquidated", type text}, {"Original Commitment", type number}, {"Current Commitment", type number}, {"Contributions", type number}, {"Distributions", type number}, {"NAV", type number}, {"Last Reported NAV", type number}, {"Last Reported NAV Date", type date}, {"Unfunded", type number}, {"Exposure", type number}, {"DPI", type number}, {"RVPI", type number}, {"TVPI", type number}})
in
Source)

********************************************

 

Initiall I was thinking of having the user of the card select the paramaeters and then trigger the API. If you have any insignt on how to use variable parmanteres and then trigger APIs i will appreciate the info.

I am traying to trigger an api per row and have the payload populated next to the ID column. 

 

Thanks for all the help. 

Substract rows from the same column

$
0
0

Hello, I´m tryin to substract rows from the same column (FPR), I need to substract the next value from the previous value acorrding to the date like this: FPR from 30/04/2019 - FPR from 31/03/2019, then 30/05/2019 - 30/04/2019 etc ...

 

restar valores misma columna.PNG

Creat mutiple columns based on a column from another table

$
0
0

Hey guys!

 

I want to create mutiple columns in the first table with headers from the colunmn "tag_name" in table 2 
(like "1940s", "american", "funky", etc.), and then check whether the column "tags" in table 1 contain it. If yes, fill 1, if no, leave it blank. TIs there any way I can fast import the colunmn "tag_name" in table 2 as the column headers in table 1? If not, is there any fast way I can use the words from column "tags" in table 1 to create new columns and check whether "tags" contain it? I know that I can use "conditional column" button under "Add Column" but I can only create one new column at once and I have 115 tags here.

 

Thank you in advanced!

Capture 1.PNGCapture 2.PNG


Error while "Refreshing" custom connector in Power BI Service

$
0
0

Hi, I made a custom connector for QuickBooks Online(Because Power BI default connector was not returning values from "Invoice" and Invoice related tables). I am able to get the data and publish in Power BI Desktop. I have included it in the enterprise gateway and able to see my report in Power BI Service, but on refresh from service I am recieving this error.
Underlying Error Message: "Value cannot be null: Parameter name: access Token Table: Invoice"

DM_ErrorDetailNameCode_UnderlyingHResult: -2147467261
I am pasting my OAuth Codes for reference.

// Data Source Kind description
PBIServiceRefresh = [
    TestConnection = (dataSourcePath) => { "PBIServiceRefresh.Contents" },
    Authentication = [
        OAuth = [
            StartLogin = StartLogin,
            FinishLogin = FinishLogin,
            Refresh = Refresh,
            Logout = Logout
        ]
    ],
    Label = "QBO Invoice Connector"    
];
// StartLogin function definition
StartLogin = (resourceUrl, state, display) =>
    let
        authorizeUrl = authorize_uri & Uri.BuildQueryString([
            client_id = client_id,  
            redirect_uri = redirect_uri,
            state = state,
            scope = "com.intuit.quickbooks.accounting",
            response_type = "code",
            response_mode = "query",
            login = "login"    
        ])
    in
        [
            LoginUri = authorizeUrl,
            CallbackUri = redirect_uri,
            WindowHeight = 720,
            WindowWidth = 1024,
            Context = null
        ];
// FinishLogin function definition
FinishLogin = (context, callbackUri, state) =>
    let
        parts = Uri.Parts(callbackUri)[Query],
        result = if (Record.HasFields(parts, {"error", "error_description"})) then 
                    error Error.Record(parts[error], parts[error_description], parts)
                 else
                    TokenMethod("authorization_code", "code", parts[code])
    in
        result;
// Refresh and Logout functions
Refresh = (resourceUrl, refresh_token) => TokenMethod("refresh_token", "refresh_token", refresh_token);
Logout = (token) => logout_uri;
// TokenMethod definition
TokenMethod = (grantType, tokenField, code) =>
    let
        queryString = [
            grant_type = "authorization_code",
            redirect_uri = redirect_uri,
            client_id = client_id,
            client_secret = client_secret
        ],
        queryWithCode = Record.AddField(queryString, tokenField, code),
        tokenResponse = Web.Contents(token_uri, [
            Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),
            Headers = [
                #"Content-type" = "application/x-www-form-urlencoded",
                #"Accept" = "application/json"
            ],
            ManualStatusHandling = {400} 
        ]),
        body = Json.Document(tokenResponse),
        result = if (Record.HasFields(body, {"error", "error_description"})) then 
                    error Error.Record(body[error], body[error_description], body)
                 else
                    body
    in
        result;

Using this connector I am able to refresh in PowerBI Desktop.
Can anyone tell me what could be the problem?

Thanks in advance.

How to add multiple "calculated columns" in Power Query?

$
0
0

For Example, I want to add 2 columns using power Query by making a measure of subtraction on 4 columns from my CCL table. Let I have these 4 columns:

MAT Value 19        MAT Value 18           MTH 19        MTH 18

I want to calculate:

MAT Diff= [MAT Value 19] - [MAT Value 18]

MTH Diff= [MTH 19] - [MTH 18]

i.e, I want to use the following query for multiple subtractions.

= Table.AddColumn(#"Changed Type1", "Subtraction", each [MAT_VALUE_19] - [MAT_VALUE_18], type number)

How to add values xx, yy from Column A as new values in Column C and Column D

$
0
0

HI everyone,

 

i'm kinda stuck. Just to let u know, i'm fairly new to Power Query. I want to add new columns (in pic.2 its "CT1" and "CT3") which contains the values of Colum "Counted Qty" from all following records with the same value in Column "Location". I cant get it to work. Tried searching and googling but couldnt find a solution. I guess that can be achieved in M-Code, but i really cant work it out.

 

Would be very nice if someone could give me a hint (or even a solution)... 

 

formumSheetOriginal.JPGOriginalformumSheetResult.JPGresult ?

Sample Data:

 

DateTransaction TimeList IDLocationSKUTag IDOriginal QtyUpdate QtyCounted QtyTempTag
10/07/20190.49130800000446081C08175BB29059475G01326670459-1049G013266704
10/07/20190.48893500000446001C08175BB29059475G013266704491059G013266704
10/07/20190.40350700000445981C08175BB29059475G01326670448149G013266704
10/07/20190.37530100000445981C08161BBABW5X50G013553562606G013553562
10/07/20190.37494200000445981C08162BB76689150G01237894323023G012378943
10/07/20190.37425900000445981C08163BBNOINVENTORY  0 1C08163BB-NOINVENTORY
10/07/20190.37414400000445981C08164BB76689146G01237893724024G012378937
10/07/20190.37329900000445981C08165BB76689078G01237894013013G012378940
10/07/20190.37231500000445981C08166BB76689145G01237892324024G012378923
10/07/20190.37076400000445981C08171BBNOINVENTORY  0 1C08171BB-NOINVENTORY
10/07/20190.37067100000445981C08173BBNOINVENTORY  0 1C08173BB-NOINVENTORY
10/07/20190.36858800000445981C08176BBNOINVENTORY  0 1C08176BB-NOINVENTORY
10/07/20190.36847200000445981C08181BBNOINVENTORY  0 1C08181BB-NOINVENTORY
10/07/20190.3683800000445981C08182BB76687981G013050341404G013050341
10/07/20190.36700200000445981C08184BB155430G01326514067067G013265140
10/07/20190.36621500000445981C08185BBNOINVENTORY  0 1C08185BB-NOINVENTORY
10/07/20190.36615700000445981C08186BBNOINVENTORY  0 1C08186BB-NOINVENTORY

Calendar: Get the last date after filter

$
0
0

Hello Geniuses,

 

I have 1 Main table with a "Date" column, then I made a new table with this formula "

Rolling periods = CALENDAR (FIRSTDATE('Income Periodical'[Date]),LASTDATE('Income Periodical'[Date]))" 
 
However, what I want is, If I filter the dates using slicer from the Main table, the new table should refresh too.
 
Example:
 
Main Table
Itemdate
11-Jan
21-Feb
31-Mar
41-Apr
51-May
61-Jun
71-Jul
81-Aug
9

1-Sep

 

New Table

 

Date
1-Jan
2-Jan
3-Jan
4-Jan
5-Jan
6-Jan
7-Jan
8-Jan
until December 31

 

If I filter Main table from the Report, NOT IN THE TABLE, I want that the New table will refresh.

 

Main Table filtered until March

Itemdate
11-Jan
21-Feb
31-Mar

 

New Table 

Date
1-Jan
2-Jan
3-Jan
4-Jan
5-Jan
6-Jan
7-Jan
8-Jan
until March 31

 

 

Hope you can help me, I've been looking for this one for almost 1 week LOL. 

Unexpected error: Value cannot be null Parameter name: Type

$
0
0

Hi All,

I am reporting on survey sent to contacts in D365 using power Bi, in power Bi, I am trying to retrieve the account linked to the contact that particpated in the survey, when i expanded the the regarding:contact table in the query editor, the contacts shows, but the corresponding accounts column is throwing an error of a null value.

What i'm doing wrong here ?

Data Model Missing a Column Automatically Created in Power Query

$
0
0

I am running a refresh of Power Query in excel 2013. The Query pulls from a source excel file. The source excel file contains multiple columns, one of which is a Year columns (about 700k rows, listing years 2013 - 2019). We received new 2019 information and Query is built to list distinct Years from source data as new columns, which i can see it does in the query editor preview pane.

 

My problem is the data model does not show this newly created 2019 column. I can't manage table properties in  the data model, as an error message notes the data was imported using Query and therefore can only be changed in Power Query. The 2019 column is also a selected viewing column in the Query Editor. Any thoughts?

ODBC Error - Key value in connection string too long

$
0
0
Odbc.Query(
    "driver={iSeries Access ODBC Driver};" &
    "system=AS400.OURCOMPANY.COM;" &
    "dsn=dBASE Files"
    ,
    "SELECT * "&
    "FROM AS400DB.JOBSCOPEDB.EPOPERF"
)

I can run this query without an issue from within Excel, but in Power BI, I get this error:image.png

 


Substract the value of the first date and last date of each year

$
0
0

Hi  

 

I have to take the first and last value of FPR of each year in the table and substract those values

 

For example for year 2019: 20707.28 (26/12/2019 last date of 2019)-2982.06 (31/03/2019 first date of 2019), and then for the next years that can be infinite ( 2020, 2021 2022, 2023 etc ....)

 

restar valores misma columna.PNG

I am trying to achieve something similar with Dax. Is it possible?

$
0
0

when position(':' in actionname)<> 0 then 'People Search'
when left(actionname, 6)='LOGOUT' then 'LOGOUT'
else actionname
end as actiongroup,

YTD in Rolling13 months

$
0
0

Hello geniuses,

 

Can someone help me please to figure out how to make this formula become YTD rolling for 13 months;

 

"13 month YTD = CALCULATE('Income Periodical'[ValueSelected],DATESINPERIOD(Periods[Date],MAX(Periods[Date]),-13,MONTH))"

 

The formula above is rolling 13 months with their monthly value, and I want to have a new formula to make a cumulative amount or YTD.

 

Thank you in advance.

Modify timestamp across many (20) tables by batch process

On-Prem Gateway - Enterprise mode - oAuth2 authentication with refresh token

$
0
0

Hi,

 

We are using the on-prem gateway in enterprise mode with a custom connector to refresh an oAuth2 protected odata service. Each time you request a new access token from this service you also get a new refresh token and the previous refresh token is invalidated (this behaviour is optional in the oAuth2 RFC).

 

In the desktop version of Power BI refreshing data with our custom connector works just fine. The desktop version also seems to respect the expiration date of the access token.

 

However, using the gateway and the Power BI service, the expiration time of the access token seems not to be respected. The service always requests a new access token using the refresh token. The service also requests a new token for each source (even if they are part of the same connection). This results in multiple requests for new refresh tokens (almost simultaneously) that seem to cross each other, which results in the fact that the second, third, etc call is done with an already invalidated refresh token, which in turn results in an access denied by the oData service.

 

Why is the desktop version and the service behaviour different? Does anybody have experience with the same issues?

 

Thank you

 

Robert 

Viewing all 31319 articles
Browse latest View live


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