Quantcast
Channel: All Developer posts
Viewing all 49216 articles
Browse latest View live

Re: Power BI Embedded and Azure Analysis Services

$
0
0

Did you ever find a solution for this?  Got the exact same issue here.


Python plot showing no output - Powerbi

$
0
0

Hi guys,

 

I'm a bit new in python but my code is working on spyder or jupyter notebook.

The equivalent script I'm running on PowerBi is the following :

 

Below is the code I used to import my data.
 
import pandas as pd
import numpy as np
from sklearn import metrics

from sklearn.model_selection import StratifiedShuffleSplit,StratifiedKFold
from sklearn.model_selection import LeavePGroupsOut
from sklearn.model_selection import GroupKFold
from sklearn.pipeline import Pipeline
import random

from sklearn import tree
from sklearn.metrics import accuracy_score
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score
from sklearn import metrics


df_order_t = pd.read_csv('C:/Users/morgan.quezel-ambrun/Documents/Stage_MBA/order_products_train.csv', dtype={
            'order_id': np.int32,
            'product_id': np.uint16,
            'add_to_cart_order': np.int16,
            'reordered': np.int8}, engine='python')
products= pd.read_csv('C:/Users/morgan.quezel-ambrun/Documents/Stage_MBA/products.csv',dtype={
        'product_id': np.uint16,
        'product_name': np.str,
        'aisle_id': np.uint8,
        'department_id': np.uint8})

orders = pd.read_csv('C:/Users/morgan.quezel-ambrun/Documents/Stage_MBA/orders.csv',dtype={
        'order_id': np.int32,
        'user_id': np.int32,
        'eval_set': 'category',
        'order_number': np.int16,
        'order_dow': np.int8,
        'order_hour_of_day': np.int8,
        'days_since_prior_order': np.float32})

aisles = pd.read_csv('C:/Users/morgan.quezel-ambrun/Documents/Stage_MBA/aisles.csv',dtype={
        'aisle_id': np.uint8,
        'aisle': np.str})

departments = pd.read_csv('C:/Users/morgan.quezel-ambrun/Documents/Stage_MBA/departments.csv',dtype={
        'department_id': np.uint8,
        'department':np.str})

orders_train = orders.loc[orders['eval_set'] == 'train']
merged_ = pd.merge(df_order_t,orders_train,on='order_id',how='left')
del merged_['eval_set']
del merged_['order_id']

 

Below the library used:
import pandas as pd
import numpy as np
from sklearn import metrics

from sklearn.model_selection import StratifiedShuffleSplit,StratifiedKFold
from sklearn.model_selection import LeavePGroupsOut
from sklearn.model_selection import GroupKFold
from sklearn.pipeline import Pipeline
import random

from sklearn import tree
The script: Basically I am creating a plot of my accuracy score depending on the depth of my tree for my training set and validation set.
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
# dataset = pandas.DataFrame(add_to_cart_order, days_since_prior_order, order_dow, order_hour_of_day, order_number, product_id, reordered, user_id)
# dataset = dataset.drop_duplicates()
# Paste or type your script code here:

X = dataset.values
y = dataset.reordered.values

groups = dataset.user_id.values
group_kfold = GroupKFold(n_splits=5)
group_kfold.get_n_splits(X, y, groups)

for train_index, test_index in group_kfold.split(X, y, groups):
    X_train, X_test = X[train_index], X[test_index]
    y_train, y_test = y[train_index], y[test_index]

X_train = pd.DataFrame(X_train.astype(int), columns=['product_id',
'add_to_cart_order',
'reordered',
'user_id',
'order_number',
'order_dow',
'order_hour_of_day',
'days_since_prior_order'])
X_train = X_train.drop('reordered', 1)
X_train = X_train.drop('user_id',1)
X_train = X_train.drop("product_id",1)

X_test = pd.DataFrame(X_test.astype(int), columns=['product_id',
'add_to_cart_order',
'reordered',
'user_id',
'order_number',
'order_dow',
'order_hour_of_day',
'days_since_prior_order'])
X_test = X_test.drop('reordered', 1)
X_test = X_test.drop('user_id',1)
X_test = X_test.drop("product_id",1)

y_train = pd.DataFrame(y_train,columns=['reordered'])
y_test = pd.DataFrame(y_test,columns=['reordered'])

max_depths = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
training_accuracies = []
testing_accuracies = []

for max_depth in max_depths:

    dtc = tree.DecisionTreeClassifier(criterion="entropy", max_depth=max_depth, min_samples_split=0.05)
    dtc_fit = dtc.fit(X_train,y_train)

    prediction_training = dtc_fit.predict(X_train)
    training_accuracy = dtc_fit.score(X_train, y_train)
    training_accuracies.append(training_accuracy)

    prediction_testing = dtc_fit.predict(X_test)
    testing_accuracy = dtc_fit.score(X_test, y_test)
    testing_accuracies.append(testing_accuracy)

import matplotlib.pyplot as plt
plt.plot(max_depths, training_accuracies, max_depths, testing_accuracies,linewidth=2.0)

plt.title('Accuracy Score', fontsize = 20)
plt.xlabel("Max depth", fontsize=20)
plt.ylabel("Accuracy", fontsize = 20)
plt.legend(['Validation set', 'Train set'], loc='upper right')

plt.show()
My output should be:
image.png
 
I have two issues with Powerbi.
 
My output is weird as I have the following results:
image.png
If I want to specify a bit more where my axis starts (STEP I NEED , to properly visualise my graph)
plt.axis([0, 21, 0.58, 0.7])
My output turns to be empty
image.png
I have no message of error...
 
Thank you a lot for your help

Dataset not refreshing via API in Power BI web service& headers not being paased

$
0
0

Hello,

I have setup a new datasource in PowerBI desktop to get data over an API (see below).

API Issue.PNG

 

Everthing works fine locally, and I'm able to refrersh the data in PBI desktop, however when I publish the report to PBI web, and try to refresh the data, I receive the following error; 

The credentials you provided for the data source are invalid. Please check the credentials for all the data sources.
Please try again later or contact support. If you contact support, please provide these details.

 

I have no idea as to why the headers are not being passed through to the PBI Web.

This is what I see see in PBI web;

PBI Web.PNG

 

Please help! 

Get data using Rest API (post)

$
0
0

Hello

 

I have this url

https://api.statbank.dk/v1/data

 

and I want to use this request for getting data for PowerBI.

{
"table": "ls01",
"format": "CSV",
"valuePresentation": "Value",
"timeOrder": "Ascending",
"delimiter": "Semicolon",
"variables": [
{
"code": "BRANCHE",
"values": [
"*"
]
},
{
"code": "ENHED",
"values": [
"*"
]
},
{
"code": "Tid",
"values": [
"2010",
"2018"
]
}
]
}

 

I have never used API's for getting data into PowerBI, hence a step-by-step guide would be very much appreciated!

Thank you :-)

Re: Embedded adding two semi colons to report container iframe

$
0
0

Our PM assumes this will be fixed soon, since it affects all PBI embedded customers. How naive... Smiley Sad

Stream Analytics with power BI Output

$
0
0

Hi Everyone,
I have created a stream analytics job with power BI output,in which i am pulling data from two sourcesSmiley Surprisedne is from event hub and other is a reference input data from sql. In the main query of this job, i have created several power Bi outputs.

In Power BI side i have created one live dashboard in which i am getting data from these outputs.(I have tested the query from stream analytics side by giving a sample inputs and all output results are showing correct values)
But in a dashboard side i am facing a data discrepancy. 
For example : I have a tile in a dashboard which displays total event lets say 50 and then i have another tile which displays total by Client which will also shows total count of 50.
But in third tile if i am displaying data by client wise communication type total then i am facing a data discrepancy .
(for example : In a second tile if client no 1234 have total events 30 then in third tile total by all communication type will not be 30 for client no 1234 . Total distribution will be any random number)
I have observed that if i am grouping on more than 1 column (here in third  tile client and Comm type) then i am facing the data discrepancy issue.
Is anyone facing same issue or can anybody please guide me on this?

Thanks

Namita

Power Shell script to push data to Power BI API

$
0
0

All,

 

NOTE: I am not a developer, trying to do the below from an online example.

 

I am using the following power shell script to push data to a power BI API and data set. It used to work fine, but then I started getting the following error

======================================

Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At line:28 char:5
+ Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestM
ethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMeth
odCommand

=================================

Script is pretty simple - just getting local machine stats and posting to power BI API

 

$endpoint = "https://api.powerbi.com/beta/de3e5d90-25ee-443e-908a-0590e39c4dff/datasets/abfa7618-cc8e-49c3-bffe-09407c7fadff/rows?key=olVUwVXCfPo9etfcHofuq4cBU3mhTUoevK4JMxrGrnSGRTPECYb7tHCDOLrtRRZbZjQwtDOJORpiFHsYqe5wBg%3D%3D"

while($true)
{

$ComputerCPU = (Get-WmiObject -Class win32_processor -ErrorAction Stop | Measure-Object -Property LoadPercentage -Average | Select-Object Average).Average

$ComputerMemory = Get-WmiObject -Class win32_operatingsystem -ErrorAction Stop
$UsedMemory = $ComputerMemory.TotalVisibleMemorySize - $ComputerMemory.FreePhysicalMemory
$Memory = (($UsedMemory/ $ComputerMemory.TotalVisibleMemorySize)*100)
$RoundMemory = [math]::Round($Memory, 2)

$Date = Get-Date -DisplayHint Date -Format MM/dd/yyyy

$Time = Get-Date -DisplayHint Time -Format HH:mm:ss

#$RoundMemory
#$ComputerCPU
#$Date
#$Time

$payload = @{
"Date" =$Date
"Time" =$Time
"CPU" = $ComputerCPU
"Memory" = $RoundMemory
}
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))

Write-Host "Date: " $Date " Time: " $Time " CPU: " $ComputerCPU " Memory: " $RoundMemory

sleep 2
}

============================

Why would this suddenly stop working?

If I hit the full url : https://api.powerbi.com/beta/de3e5d90-25ee-443e-908a-0590e39c4dff/datasets/abfa7618-cc8e-49c3-bffe-09407c7fadff/rows?key=olVUwVXCfPo9etfcHofuq4cBU3mhTUoevK4JMxrGrnSGRTPECYb7tHCDOLrtRRZbZjQwtDOJORpiFHsYqe5wBg%3D%3D

I get a 404

If I hit : https://api.powerbi.com/beta/de3e5d90-25ee-443e-908a-0590e39c4dff/datasets/abfa7618-cc8e-49c3-bffe-09407c7fadff/

I get a 403

 

can someone help me fix this?

 

Thanks

Ravina

Re: Embedded adding two semi colons to report container iframe

$
0
0

Looks like its been fixed, at least on my tenant.  The pro's and con's of cloud.


Push New pbix file using PBIRS API Method /PowerBIReports({Id})/Model.Upload

$
0
0

Seems like there is an issue with POST upload method when trying to upload a new pbix file. While the description of this method says:

 

Does an efficient binary upload of a new or existing PowerBIReport CatalogItem from a multipart/form-data request. Use of this API is recommended for files larger than 25 MB in size. (https://app.swaggerhub.com/apis/microsoft-rs/pbirs/2.0#/PowerBIReports/UploadPowerBIReport)

 

One of the parameters that is required is causing it to fail. It has to have the path or GUID on the server to the pbi file you are trying to upload. Obviously if I am uploading a new report there wouldn’t be a path or GUID on the server because that object doesn’t exist yet. I’ve tried calls just using the location I would like the report to be uploaded to but I get an object not found error. Probably because it’s a new report and it doesn’t exist on the server.

 

Call I made using the path I would like the new report to be uploaded to:

curl -vX --ntlm -u username POST "https://server/Reports/api/v2.0/PowerBIReports(path='/New_Folder_Test/example')/Model.Upload" --header "accept: application/json" --header "Content-Type: multipart/form-data" --form File=@example.pbix

 

Response (notice it finds the file I want to upload but can’t locate):

Enter host password for user 'username':

* STATE: INIT => CONNECT handle 0xa2f160; line 1392 (connection #-5000)

* Rebuilt URL to: POST/

* Added connection 0. The cache now contains 1 members

* STATE: CONNECT => WAITRESOLVE handle 0xa2f160; line 1428 (connection #0)

* Could not resolve host: POST

* Closing connection 0

* The cache now contains 0 members

curl: (6) Could not resolve host: POST

* STATE: INIT => CONNECT handle 0xa2f160; line 1392 (connection #-5000)

* Added connection 1. The cache now contains 1 members

* STATE: CONNECT => WAITRESOLVE handle 0xa2f160; line 1428 (connection #1)

*   Trying 10.176.72.85...

* TCP_NODELAY set

* STATE: WAITRESOLVE => WAITCONNECT handle 0xa2f160; line 1509 (connection #1)

* Connected to server (10.176.72.85) port 443 (#1)

* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0xa2f160; line 1561 (connection #1)

* Marked for [keep alive]: HTTP default

* ALPN, offering h2

* ALPN, offering http/1.1

* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH

* successfully set certificate verify locations:

*   CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt  CApath: none

* TLSv1.2 (OUT), TLS header, Certificate Status (22):

* TLSv1.2 (OUT), TLS handshake, Client hello (1):

* STATE: SENDPROTOCONNECT => PROTOCONNECT handle 0xa2f160; line 1575 (connection #1)

* TLSv1.2 (IN), TLS handshake, Server hello (2):

* TLSv1.2 (IN), TLS handshake, Certificate (11):

* TLSv1.2 (IN), TLS handshake, Server key exchange (12):

* TLSv1.2 (IN), TLS handshake, Server finished (14):

* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):

* TLSv1.2 (OUT), TLS change cipher, Client hello (1):

* TLSv1.2 (OUT), TLS handshake, Finished (20):

* TLSv1.2 (IN), TLS change cipher, Client hello (1):

* TLSv1.2 (IN), TLS handshake, Finished (20):

* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384

* ALPN, server did not agree to a protocol

* Server certificate:

*  subject: CN=*.domain.regn.net; O=RELX Inc.; L=New York; ST=New York; C=US

*  start date: Apr  2 13:28:15 2018 GMT

*  expire date: Apr  1 19:28:15 2020 GMT

*  subjectAltName: host "server" matched cert's "*.domain.regn.net"

*  issuer: C=US; ST=Illinois; L=Chicago; O=Trustwave Holdings, Inc.; CN=Trustwave Organization Validation SHA256 CA, Level 1; emailAddress=ca@trustwave.com

*  SSL certificate verify ok.

* STATE: PROTOCONNECT => DO handle 0xa2f160; line 1596 (connection #1)

* Server auth using Basic with user 'domain\username'

> --ntlm /Reports/api/v2.0/PowerBIReports(path='/New_Folder_Test/example')/Model.Upload HTTP/1.1> Host: server> Authorization: Basic basichashpw> User-Agent: curl/7.58.0> accept: application/json> Content-Length: 532896957   (finds local file fine)> Content-Type: multipart/form-data; boundary=------------------------ee0faf19e3769bfb> Expect: 100-continue> 

* STATE: DO => DO_DONE handle 0xa2f160; line 1658 (connection #1)

* STATE: DO_DONE => WAITPERFORM handle 0xa2f160; line 1783 (connection #1)

* STATE: WAITPERFORM => PERFORM handle 0xa2f160; line 1799 (connection #1)

* HTTP 1.1 or later with persistent connection, pipelining supported

< HTTP/1.1 404 Not Found< Cache-Control: no-cache< Content-Length: 227< Content-Type: application/json; odata.metadata=minimal

* Server Microsoft-HTTPAPI/2.0 is not blacklisted

< Server: Microsoft-HTTPAPI/2.0< X-Content-Type-Options: nosniff< Set-Cookie: XSRF-NONCE=nonce%3D; path=/Reports; HttpOnly< Set-Cookie: XSRF-TOKEN=deprecated; path=/Reports< OData-Version: 4.0< Date: Mon, 09 Sep 2019 16:14:58 GMT

* HTTP error before end of send, stop sending

* Marked for [closure]: Stop sending data before everything sent

< 

{

  "error":{    "code":"","message":"No HTTP resource was found that matches the request URI 'http://server/Reports/api/v2.0/PowerBIReports(path%3D'/New_Folder_Test/example')/Model.Upload'."  }   expects an existing report called example. So how can this be used for new files?

}* STATE: PERFORM => DONE handle 0xa2f160; line 1968 (connection #1)

* multi_done

* Closing connection 1

* The cache now contains 0 members

* TLSv1.2 (OUT), TLS alert, Client hello (1):

* Expire cleared

 

I tried with just the existing folder and got the same:

curl -vX --ntlm -u domain\username POST "https://server/Reports/api/v2.0/PowerBIReports(path='/New_Folder_Test')/Model.Upload" --header "accept: application/json" --header "Content-Type: multipart/form-data" --form File=@example.pbix

 

Response error:

{  "error":{    "code":"","message":"No HTTP resource was found that matches the request URI 'http://server/Reports/api/v2.0/PowerBIReports(path%3D'/New_Folder_Test')/Model.Upload'."  }

 

A call to get the folder metadata works fine:

curl -v --ntlm -u domain\username GET https://server/Reports/api/v2.0/Folders(path='/New_Folder_Test') --header "Content-Type: application/json"

Response:

{  "@odata.context":"http://server/Reports/api/v2.0/$metadata#Folders/$entity","Id":"62764f50-8479-40ef-9cc0-2ba2fecfb360","Name":"FIDO_Testing","Description":null,"Path":"/FIDO_Testing","Type":"Folder","Hidden":false,"Size":0,"ModifiedBy":"domain\\username","ModifiedDate":"2019-09-05T11:18:51.413-04:00","CreatedBy":"domain\\username","CreatedDate":"2019-08-28T15:19:19.877-04:00","ParentFolderId":"fac77548-84a9-488b-aeca-14607954dc30","IsFavorite":false,"Roles":[  ],"ContentType":null,"Content":""

}

 

Re: Embedded adding two semi colons to report container iframe

$
0
0

Fixed in my embedded page as well.

Python scrips works for all?

$
0
0

I have a question, If I use a python script in my PowerBI Report, I make graphs with thee output of that python script, it will be available and updatable to other people? I mean people without python installed.

Because to make a script I need have installed python, but other people like managers would not have it.

 

Thanks for you aswerds

Re: "pbiviz package" does not update visual's capabilities, but "pbiviz start" d

$
0
0

Hi ,

To test updating an already published visual in Power BI Desktop, the only solution I've found that works for me is to temporarily modify the GUID, package and test, as per this post's solution. It makes it tricky ensuring that everything is ready prior to submission to the marketplace - although as long as the latest version of your visual code is uploaded into your sampl workbook, even though it displays the previous version, it will submit okay.

Alternatively, I've had mixed results by using tools such as clumsy to block access to my network when I load the visual via desktop so that the CDN call can't go through and load the marketplace version. This isn't always consistent for me though, so the GUID change is usually what I do.

Not sure if this helps much, but thought I'd weigh in.

Daniel

Re: Get data using Rest API (post)

Re: Dataset not refreshing via API in Power BI web service& headers not being paased

$
0
0

Hi  

 

Please see my answer in the below link.

https://community.powerbi.com/t5/Service/Refreshing-data-from-REST-API-works-on-Desktop-fails-on-Service/td-p/779926

 

Your api is using api-key autentication which is not currently directly supported by PowerBI service. Bcoz PowerBI Service only allow API autentication with anonymus , Windows and Basic

 

The workaround is to use a Gateway and Skip Test Connection 

 

https://community.powerbi.com/t5/Community-Blog/Power-BI-Gateway-Monitoring-amp-Administrating-Part-2/ba-p/750765 

 

 

Re: "New Look" - Power BI Embedded


Re: power bi RLS doesn't render filtered report while using embed token with effective identity

$
0
0

Hi Sannjana,

 

Are your correctly passing the username and roleslist ?

 

Please include some additional conditions

 

if (datasets.IsEffectiveIdentityRolesRequired == true)
                    {
                        if (username != null && rolesList != null && rolesList.Count()>0)
                        {
                            generateTokenRequestParameters = new GenerateTokenRequest("view", null, identities: new List<EffectiveIdentity> { new EffectiveIdentity(username: userName, datasets: new List<string> { report.DatasetId }, roles: rolesList) });
                        }

Also please see the official document reference 

https://docs.microsoft.com/en-us/power-bi/developer/embedded-row-level-security#applying-user-and-role-to-an-embed-token

 

 

Re: power bi RLS doesn't render filtered report while using embed token with effective identity

$
0
0

  yes I am passing the username and roleslist, even i have tested with static values for roles and username but the result was the same. The Power BI tenant and Organization tenant I am using are different active directories and I am using Service account for authentication and the username passed is different can this be the issue for it?

 

Although all the documentation available states that the username and role are mandatory. Is there any roadmap where we can avoid adding members to the roles and only passing role would workout.

 

Thanks!

Re: "pbiviz package" does not update visual's capabilities, but "pbiviz start" d

$
0
0

Power BI Desktop caches custom visuals and downloads the latest version of the visuals from the CDN network once in a while. Probably that is the reason that clumsy is not always working.

 

So indeed changing the GUID to a temp version is the preferred way to (extra) test your visuals in Power BI Desktop.

 

-JP

Power BI Pro licence installation

$
0
0

Hi all!

 

Last year my organization bought several Power BI Pro licence. This year we want to start using them. Licences are payed, but our IT support team doesn't know how to install them. 

 

We have a local Power BI Server, licences were bought from microsoft authorised partner (separately from pwer BI Server, which was installed as a part of Microsoft Enterprise licences).

 

Any idea how to assign licences to users? 

custom chart highlighted point not retained on drilldown and drillup in other visuals

$
0
0

Below Github link contains the sample bar chart,
https://github.com/kaviarasuPR/SampleBarChart3.1
When I select some point in sample bar chart, drilldown and drillup is happening in other visuals in the dashboard.  The highlighted value in sample bar chart is not retained. 
Refer video for further clarification,

HighlightAll.gif

The chart in the first row is taken from  powerbi
chart in second row is custom chart

Viewing all 49216 articles
Browse latest View live


Latest Images

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