Quantcast
Channel: Developer topics
Viewing all 17950 articles
Browse latest View live

Signon Troubles UriFormatException: Invalid URI: The hostname could not be parsed

$
0
0

Found some discussion but was all on Wepapp.

In a simple console app I would like to conect the PBI API, but i'm keep running into this error.

UriFormatException: Invalid URI: The hostname could not be parsed.

This is the very basic code ...

        private static string clientId = "Key-received-by-creating-the-app-with-pbi-portal";
        private static string ResourceUrl = @"https://analysis.windows.net/powerbi/api";
        private static string AuthorityUrl = @"https://login.windows.net/common/oauth2/authorize";
        private static string ApiUrl = @"https://api.powerbi.com/";
        private static string token;
        private static PowerBIClient pbiClient;

        static void Main(string[] args)
        {
            Console.WriteLine("Connecting ...");
            pbiClient = GetToken();
            Console.WriteLine("Conneced.");
            Console.ReadKey();
        }

        private static PowerBIClient GetToken()
        {
            var credential = new UserPasswordCredential("a.user@somedomain.be", "xyz");
            var authenticationContext = new AuthenticationContext(AuthorityUrl, false);
            var authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, clientId, credential).Result;
            var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
            var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials);

            return client;
        }

If somebody could give me a hand, i'm not a C# developper, but would like to create a simple program to define py push datasets.

 

Kind regards, Harry


Combination chart

$
0
0

I need create the chart below, but i don't saw the model in Power BI Desktop, someone know if is possible?

 

Chart.PNG

WordCloud 1.7.1 - Stop Words, Word-breaking, & Buckets

$
0
0

I'm experiencing a couple of hang ups in WordCloud and curious if there are some clever solutions out there already. 

 

I created a column of Stop Words in the table with the WordCloud text. The Excludes feature points to the Stop Words but it doesn't consistently exclude all of the words, ~70% exclusion rate. It appears to be consistent (not changing between refreshes which words it does and doesn't exclude. There are emojis in the raw text and I'm putting numbers and special characters in the Stop Words. 

 

I've toggled the Word-breaking feature on, but I'd like to capture specific phrases like "Big Data" "Program Manager". Ideally I'd like to be able to make word buckets eg "PM" "Program Manager" where PM is displayed but Program Manager is counted towards the weight. 

 

Thank you PBI community! 

How to prevent unwanted type conversion when data are passed to R transform

$
0
0
I am using an R transform to do conversion of several columns in my dataset. One of the columns that I do NOT want to transform is a text column of identifiers which are digits with leading zeros. However when this column arrives in the R environment, the data type is already "integer." Therefore when it comes back from the transform Power BI sees it as whole number, and doesn't preserve the leading zeros. It was hard to find a way to prevent this type conversion from character to numeric. If the column is already numeric when R gets it, there's no way to preserve the leading zeros. (And the number of digits and leading zeros in this column of identifiers can vary so it's hard to find a consistent way to use "paste" or "str_pad" in R to do the trick. )
 
I have found one workaround to prevent the text to numeric conversion, which is to add non-numeric content to the column before running the R transform. I use Transform-->Format-->Add prefix and put a "Z" in front of the digits (any non-digit would do), then after the R transform I remove the "Z" and this works. The data type of "character" is preserved.  Anybody have a more elegant technique to prevent the data type conversion?

 

I was also wondering if there is a way to pass to an R transform only SOME of the columns instead of the whole dataset. Is that an option?

 

 

Using PBI Premium as an ISV

$
0
0

Hello:

 

I'm super confused and hoping someone can help straighten me out.

 

We are an ISV and want to embed Power BI reports into our application, so users can both view and edit/create reports.  We were leaning towards using the Premium SKU, since it comes with a license for the on-premise Report server (and we'd like to run a hybrid solution)   We run a multi-tenant database in our own data center.

 

We authenticate users within our application, and don't want our external customers to have to sign up for a separate Power BI account in addition to the one they currently use for our application (nor do we want them to have to pay for the licenses)

 

From everything I've read, using the 'App Own Data' model would be the way to go..  However, I can't seem to get a straight answer that you can do this with Premium, as everything I've read seems to say if you're an ISV and want use this for external customers, you have to use the Embedded SKU instead.

 

Is Embedded the only way to embed reports into our application for external customers (so they don't need separate PBI accounts to view/edit reports)?

 

Thanks!

Custom Data Connector Prompt Credentials

$
0
0

Hey guys,
I'm building a custom data connector to gets data from an Rest API that doesn't support OAuth, and i was wondering if it is possible for the user to be prompted for some info, like the Base_Url and an Auth_Key on the first use, and then store that info in a text file. Then the connector would read from that file everytime. The prompt could always appear, but if it was pre-filled, that would be awesome.

I made the part that reads from the text file, but i can't figure out a way to make the "user input first" approach, work.
Is there any way to make that using the credentials part of the connector, maybe?
My connector logic is:

GetTable = (ID as text, Params as text) as table =>
    let
        authKey = LoadFromResource("Auth_Key"), // file Auth_Key.txt
        url =  LoadFromResource("BaseUrl") & "?id=" & ID & "&params=" & Params, // file BaseUrl.txt
        options = [Headers=[auth_key= authKey, #"Content-Type"="application/Json"]], 
        source = Json.Document(Web.Contents(url, options)),
        toRecords = Table.FromRecords(source),
        expanded = ExpandAllRecords(toRecords)
     in
        expanded;

[DataSource.Kind="Test1", Publish="Test1.Publish"]
shared Test1.Contents = (ID as text, Params as text) => 
     let    
          source = GetTable(ID, Params)
     in
          source;

 Thank you.

How to create a Scatter Chart with no Y Axis (numerical value) agregations

$
0
0

Hi to all,

I've a problem when I want plot the next table:TABLEEE.PNG

In X Axis I wantto plot SERIAL NUMBER, in Y Axis I want to plot DATA and in Legend the POSITION.

The problem with the Scatter Chart who has PowerBI, is that I can't put DATA with "Don't summarize"...

Basically, I want to representate all the DATA values for each SERIAL and distingish by POSITION.

I want something like this:

Capture.PNG

Thanks !!

Code to refresh a dataset where prior refresh failed

$
0
0

Hi everyone,

 

we have a number of "production" datasets, and these seem to fail to refresh occasionally. Uncertain why - maybe network hiccup, PBI service issue, database being backed up on our side, etc.

 

Long and short, I'm trying to write a script that will loop through every dataset in our production workspaces, check whether a) the dataset is set up to refresh, and b) if so did the last refresh work properly. Unfortunately I'm not a PowerShell developer (at all...) so I'm hitting some issues.

 

The main piece of code I have is:

 

$AllDatasets =
ForEach ($workspace in $Workspaces)
    {
    ForEach ($dataset in (Get-PowerBIDataset -Scope Organization -WorkspaceId $workspace.Id))
        {

        # check if dataset is supposed to refresh
        $url = "https://api.powerbi.com/v1.0/myorg/groups/" + $workspace.Id + "/datasets/" + $dataset.ID + "/refreshSchedule"
        $refreshSched = $false
        $refreshSched = (ConvertFrom-Json (Invoke-PowerBIRestMethod -Url $url -Method Get)).enabled


        # check status of last refresh
        $url = "https://api.powerbi.com/v1.0/myorg/groups/" + $workspace.Id + "/datasets/" + $dataset.ID + '/refreshes?$top=1'
        #Write-Host $url
        $last_status = "n/a"
        $last_status = (ConvertFrom-Json (Invoke-PowerBIRestMethod -Url $url -Method Get)).value.status



        [pscustomobject]@{
            WorkspaceName = $workspace.Name
            WorkspaceID = $workspace.Id
            DatasetName = $dataset.Name
            DatasetID = $dataset.Id
            DatasetAuthor = $dataset.ConfiguredBy
            Refresh = $refreshSched
            LastStatus = $last_status
            }
        }
    }

This seems to work pretty well - but it throws errors. For example, the bit of code where it calls the "/refreshSchedule" fails if the dataset isn't set to be refreshed. Ditto for when it calls the last status $top=1 bit.

 

Is there a simple way for me to test whether a dataset is set up to be refreshed, other than calling the /refreshSchedule API and getting an error back? And/or is there a better way to handle the error? I thought I could use the "IsRefreshable" field when querying the dataset itself...but that seems to be set to TRUE even for datasets that aren't scheduled to refresh.

 

Thanks!

Scott


How To Share Visual Selection Between Visuals: powerbi-visuals-tools@3.0, powerbi-visuals-api@2.2.2

$
0
0

Hello!

I'm in the process of setting up a custom slicer visual to pass a datapoint selection to several other visuals in the same report. The gist of the problem is that when select is called on the custom slicer visual, the other visuals execute their "registerOnSelectCallback" functions, but the ids parameter is always null. I doubled checked that the selection manager on the custom slicer has an id selected:

 

how-to-send-selection-to-multiple-visuals-on-single-report.gif

 

I'm using selection manager on powerbi-visuals-tools@3.0.7 (beta) and powerbi-visuals-api@2.2. Nothing related to selection is added in the capabilities.json.

 

Here's the effected portions of the custom slicer visual.ts: 

 

Constructor:

 

private target: HTMLElement;
private host: IVisualHost;
private manager: ISelectionManager;
private settings: VisualSettings;
private selectionIds: any = {};
private isEventUpdate: boolean = false;

constructor(options: VisualConstructorOptions) {
        let that = this;
       
        this.target = options.element;
        this.host = options.host;
        this.manager = this.host.createSelectionManager();
    }

 

 

Update function:

public update(options: VisualUpdateOptions) {
        if (!this.isEventUpdate) 
            this.init(options);
    }

 

Init function:

private init(options: VisualUpdateOptions) {
        let that = this;

        //clear selection ids array and element html (for select box)
        this.target.innerHTML = "";
        this.getSelectionIds(options.dataViews);

        let keys = Object.keys(this.selectionIds);

        //Create and append select list
        let select = d3.select('body')
            .append('select')
            .classed('selectbox', true)
            .on('change', function (e) {
                that.isEventUpdate = true;

                let value = select.node().value;

                // clear out any previous selection ids
                that.manager
                    .clear()
                    .then(() => {

                        // Find the selectionId and select it
                        that.manager
                            .select(that.selectionIds[value])
                            .then((ids: ISelectionId[]) => {
                                ids.forEach(function (id) {
                                    console.log(id);
                                });
                            })
                            .catch(() => {})
                            .finally(() => {
                                that.isEventUpdate = false;
                                debugger;
                            });
                    });

                (<Event>d3.event).stopPropagation();
            });

        this.target.appendChild(select.node());

        keys.forEach((item: string, index: number) => {

            let option = document.createElement("option");

            option.value = item;
            option.text = item;

            select.node().appendChild(option);
        });
    }

 

Function to get SelectionId's (e.g. a table view work-around based on v-iig's answer on the thread: https://community.powerbi.com/t5/Developer/Creating-Selection-manager-for-Custom-Table-visuals/m-p/218391/highlight/true#M6869)

 

private getSelectionIds(dv: DataView[]): ISelectionId[] {
        let dataview = dv[0];
        let that = this; 

        return dataview.table.identity.map((identity: any) => {
            const categoryColumn: powerbi.DataViewCategoryColumn = {
                source: dataview.table.columns[0],
                values: null,
                identity: [identity]
            };

            let id = that.host
                .createSelectionIdBuilder()
                .withCategory(categoryColumn, 0)
                .createSelectionId();

            that.selectionIds[`${dataview.table.columns[0].displayName}${identity["identityIndex"]}`] = id;

            return id;
        });
    }

 

Here's the affected portion of one of the visuals that is supposed to listen for the selectionId of the above custom slicer:

 

Constructor

private target: HTMLElement;
    private settings: VisualSettings;
    private svg: any;
    private app: any;

    private host: IVisualHost;
    private manager: ISelectionManager;
    private selectionIds: any = {};

    constructor(options: VisualConstructorOptions) {
        let that = this;

        that.target = options.element;
        that.svg = d3.select(options.element)
            .append('svg')
            .classed("chart", true);

        that.host = options.host;
        that.manager = that.host.createSelectionManager();
        
        that.manager.registerOnSelectCallback((ids: ISelectionId[]) => {
            //called when a selection was set by Power BI
           //note when custom slicer select is called, this function executes
           //but the ids array is empty, we expect the id selection populated though...

            debugger;
        });
    }

 

 

Any help is appreciated!

 

All the best,

Diran O.

 

Pull information from filter in lookupvalue

$
0
0
i want to use lookup value in Power BI, i'm using the following expression: the problem is, i need to pull different values from table depending the result of one filter in my page. I mean the 3 er field of lookup value could be dynamic?, if one filter i choose "Private", obtain the result for this, and if i choose "Public", change the result of "Private" to "Public".
    Type_to_Freq = LOOKUPVALUE(PP_Freq[Estimate],PP_Freq[Type],"Public")
Do you know what i need to change to use that expression? Thanks.

Adding a static js script to a custom visualization that don't have a type file

$
0
0

I am trying to add external js `@dashboardcode/bsmultiselect` in the custom visual that can be like this and I could not find a type file for this. will it work ?

 

How to access general properties Width and Height in custom visual

$
0
0

Is it possible to get Width and Height properties in code? I know these "general" properties are created by default once you add objects: {} in capabilities.json.

 

General Settings.PNGSettings

Based on some requirement and to achieve something, I want to access this width and height properties so I can modify it via code on the go.  

Embedding report fails after publishing app to Azure

$
0
0

I'm using the Power BI Javascript library to embed reports in an Angular application. Everything works perfectly when I'm running on localhost. After I publish to an Azure App Service, all the reports fail with the error

 

"message":"LoadReportFailed","detailedMessage":"Get report failed","errorCode":"403"
The configuration for the embed function call

type: 'report',
id: this.reportId,
embedUrl: embedConfig.EmbedUrl,
pageView: "fitToWidth",
accessToken: embedConfig.EmbedToken.token,
tokenType: pbi.models.TokenType.Embed,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: true
}
};

 

Anything I'm missing in Azure? I don't understand why it's working when running on localhost but not in Azure

TestConnection handler for On-Premises Data Gateway not working

$
0
0

Hey guys,
I'm trying to make my custom connector work through the on-premises data gateway, and as i've read here, i need to make a TestConnection handler. The examples given illustrate the cases when you have only an url, or multiple non url parameters.
The thing is, on my shared main function, i ask the user for an URL and other 2 parameters, and i don't know how to make it work. 
Anyone knows the syntax for this?

Thank you.

Unable to call Workspace in Service using Power shell commands

$
0
0

Hi All,

 

I am able to connect to Power bi service from powershell using command connect-PowerBIServiceAccount. But when try to call the workspaces using  Get_PowerBIworkspace i am getting below error.

 

 

PS C:\WINDOWS\system32> Get-PowerBIWorkspace
Get-PowerBIWorkspace : Operation returned an invalid status code 'Unauthorized'
At line:1 char:1
+ Get-PowerBIWorkspace
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...owerBIWorkspace:GetPowerBIWorkspace) [Get-PowerBIWorkspace], HttpOperationException
    + FullyQualifiedErrorId : Operation returned an invalid status code 'Unauthorized',Microsoft.PowerBI.Commands.Workspaces.GetPowerBIWorkspace

PS C:\WINDOWS\system32> Resolve-PowerBIError -Last


   HistoryId: 2


RequestId        : 05f5d685-34a9-4d80-9c3e-820fbb3ef520
Response         : Unauthorized (401): {"error":{"code":"UserNotLicensed","message":"User is not licensed for Power BI"}}
PowerBIErrorInfo : UserNotLicensed
ResponseDate     : Tue, 14 May 2019 14:29:29 GMT
RequestMethod    : GET
RequestUri       : https://api.powerbi.com/v1.0/myorg/groups?$top=100
InvocationInfo   : {Get-PowerBIWorkspace}
Line             : Get-PowerBIWorkspace
Position         : At line:1 char:1
                   + Get-PowerBIWorkspace
                   + ~~~~~~~~~~~~~~~~~~~~
StackTrace       :    at Microsoft.PowerBI.Api.V2.Groups.<GetGroupsWithHttpMessagesAsync>d__5.MoveNext()
                   --- End of stack trace from previous location where exception was thrown ---
                      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                      at Microsoft.PowerBI.Api.V2.GroupsExtensions.<GetGroupsAsync>d__1.MoveNext()
                   --- End of stack trace from previous location where exception was thrown ---
                      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                      at Microsoft.PowerBI.Api.V2.GroupsExtensions.GetGroups(IGroups operations, String filter, Nullable`1 top, Nullable`1 skip)
                      at Microsoft.PowerBI.Common.Api.Workspaces.WorkspacesClient.GetWorkspaces(String filter, Nullable`1 top, Nullable`1 skip)
                      at Microsoft.PowerBI.Commands.Workspaces.GetPowerBIWorkspace.GetWorkspaces()
                      at Microsoft.PowerBI.Commands.Workspaces.GetPowerBIWorkspace.ExecuteCmdlet()
                      at Microsoft.PowerBI.Commands.Common.PowerBICmdlet.ProcessRecord()
HistoryId        : 2

Cumulative difference in power BI on calculated measure.

$
0
0

Hello Team,

I want to calculate cumulative difference current minus previous based on date. but the date value is not fixed for minimum number of days it can be any date when the refresh is ran.

based on these refresh dates i need to calculate cumulative difference 

I ahve written my doubts in red what i want to calculate. and have done this calculation in excel formula but same i want to replicate on power bi. I ahve searched all but there are many complications. i ahve written step by step what i am doing and what i am looking for. Please help me. I am not able to attach the excel so i ahve attcahed the screesnhot of adta with my calculation done based on which I want other calculations. once you reply if needed share your email id so that i can mail you the excel if the image is not clear. My email id is ankita.g.vaishnav@gmail.comPower Bi Dummy data with calculation.PNGplease check this

See Records - User specific

$
0
0

Hi,

 

I am able to right click on our visualization and choose "See Records" however, my manager is not. We are both on the web version of PowerBI, both entering the report the same way, and both clicking in the same place.

I am the one who created this report, would that matter? Is there an option I can choose to enable this?

Any help would be appreciated.

adding column with DAX in query editor

$
0
0

HI, Mr/Ms genius, 

 

I cannot add a column using DAX measure in query editor.

 

The DAX measure (below) is proven valid in normal data view, but I think you cannot add a column with DAX in Query Editor. Can someone help me translate this command of creating a new column into M? Or is there any other way around this?

 

DAX: 

IsLatestChangedDateByID = TableName[ChangedDate] = 
	CALCULATE(
		LASTNONBLANK(TableName[ChangedDate], 1), 
		FILTER(ALL(TableName), TableName[ID]=EARLIER(TableName[ID]))
	)

 

I need this column to be in Query editor for me to filter the table and merge with another table. 

 

Can someone help me pls? 

 

Many thanks, 

 

Zishu

Sharing Apps or Reports in Microsoft Teams

$
0
0

Hello all,

I am hoping for some guidance. My orgaisation has just started to integrate MS Teams and we were looking to share reports within teams which looks excellent.

Currently we publish reports as Apps and share them to keep the data and reports secure from some of the less computer savvy employees.

Now that teams is being integrated i can only see that you share the reports into a new Tab on teams (easy) but for the team members to be able to see the report they have to be part of the workspace the report is in. This would then give them access to 'Edit' the report and potentially do something that affects the reports integrity.

 

Obviously sharing Apps protects the report integrity but allowing access for editing the report does not.

 

Am i missing something? RLS does not apply on this as it is not content i want to restrict but editing rights.

 

Any help or pointers would be appreciated, thanks in advance.

Does PowerbiEmbedded scheduled refresh, refresh the entire dataset or just synchronize?

$
0
0

Hi all,

 

We have set up the pbix on app.powerbi for embedding purposes and set up the gateway etc. We also set up scheduled refreshes. Does it refresh all the data or just new data generated?

 

Much appreciated.

Viewing all 17950 articles
Browse latest View live