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

Acquired token gives 401 Unauthorized when trying to create DataSet

$
0
0

Hi

im building an app to push data to a dataset in Power Bi

 

the token i got from azure does not seam to have te persissions i gave til ap in "app registrations"

the code om using to acquire the token is 

 

string resourceUri = "https://analysis.windows.net/powerbi/api";string authorityUri = "https://login.windows.net/common/";           AuthenticationContext authenticationContext = new AuthenticationContext(authorityUri);var AuthResult = authenticationContext.AcquireTokenAsync(resourceUrinew ClientCredential(ClientIDAppSecret)).Result;return AuthResult.AccessToken;

and the permissions that is grated in azure ad

pbi.png

but when i try to create the dataset it gives me an 401

i can create the dataset when i generate the token for a user with powershell but not with the token generated from client_id and client_secret

 

Hope you can help

 


Remove Top padding when embed report using iframe in web application

$
0
0

Hi All,

 

I am running one power bi report using power bi report server

when i use the embed url in browser then i can see the report is loading without any top padding.

But when the same embed url i am loading through iframe in my project then i can see there report is loading but having some top padding. Due to that the loaded report layout does not looks good.

 

I just need some one help to come out from this issue.

I did some google but that issue could not able to fix it out.

Below is the attached screen shot where i have shown both image, In Second image in top having more space.

 

PowerbiTopSpace.png

Please provide some solution to fix it out.

Thanks,

Vikash

Re: How data reduction algorithm works?

$
0
0

Hi,

 

Can you please share, what exactly did you change to fix this

Token received from embedded API does not respect TokenLifetimePolicy that has been set in policies

$
0
0

I require the embed tokens I receieve back from the embedded API to live longer than the defaulted hour. I followed the information here

 

https://docs.microsoft.com/en-gb/azure/active-directory/develop/active-directory-configurable-token-lifetimes#example-token-lifetime-policies

 

and set a new policy for "AccessTokenLifetime" with the following

 

 New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"23:59:59"}}') -DisplayName "WebPolicyScenario" -IsOrganizationDefault $false -Type "TokenLifetimePolicy"

   

I then assigned this policy to my application using the Add-AzureADApplicationPolicy command.

 

However the tokens I get back still have one hour expiration, is there something I am missing? I have also tried setting MaxAgeSessionSingleFactor, but with no success.

 

Thanks

Re: browse pages without changing the report level filter

$
0
0
You may use drillthrough where the field you want to filter on should be used in the next tab. This way when you right click on one of the line and click drillthrough it will take you to another tab with data pertaining to the line you clicked on in previous tab

Re: Custom Visual update options.updateId

$
0
0

Thank you Daniel for your response.  You brought up some interesting points that I will find useful, but they don't resolve what I'm after.  I don't think I was clear enough in asking my question.

 

I'm working with hierarchies in a matrix grid and I would like to be able to programatically control expand up and down. 

 

I know of only selectionManager.select(dataPoint) for drilling down.  I haven't found a method (or API) to drill up, or drill to a specific level, or return to top level dataView.

 

I can use selectionManager.select(dataPoint) to drill down on the current dataView.  But that brings a new dataView and even if I held onto the previous dataView, Power Bi only knows about the current dataView.  If I attempt to drill down on another dataPoint from the previous dataView it has no meaning to Power Bi and nothing is returned.  A key issue is that the dataPoint identifiers are unique only to the dataView and not to the data that they represent.  So a hierarchy member in different dataViews can have different identifiers. When I saw the UpdateId (even though not officially exposed in the definition) I was hoping it may be a way to reference a dataPoint from a previous dataView in a select call.

 

At a minimum, I'm looking for code that can get Power Bi to return to the top level dataView.  I can then from there navigate down to where I want to go.

 

As an aside, in regards to VisualUpdateType, I've been confused by the meaning of VisualUpdateType.style=16.   I assumed it meant changes made in the Format/Style panel of the editor.  But when I make a change, I'm getting type = data (2), not style (16).  Can you tell me what style represents, or is there another issue taking place?

 

Thanks again for your timely response and any further help.

Regards,

Bruce

Export selected data to an API from Power BI

$
0
0

Hi everyone!

 

I'm a newbie in PBI and I have this situation: the business area wants to export filtered data from a report in PBI to send this data to an APP through an API; I have tried so many ways, is there any way to do this?

Adding a Second Measure to Custom Visual

$
0
0

 

I am new to programming and not even really sure how to ask this question.  Please let me know if anyhting is unclear or you need more information, but here it goes:

 

I am creating my first custom visual in Power BI.  I want to have overlapping bar charts.  I found an example/tutorial online showing how to create a simple bar chart.  I was able to modify the visual to get the two overlapping bar charts, and the custom visual is looking exactly how I want it (see below).

Capture.JPG

 

The problem is that the example I modified restricted the visual to only using one measure (that is why in the screenshot the thin yellow and fat green bars are exactly the same height - they are both based on the same set of values).  I was able to change the capabilities file to allow for 2 measures.  However, I can't figure out how to make it so the second set of bars (yellow bars) uses the second measure.  Can someone help point me in the right direction?

 

Below is the visual.ts file.  Please let me know if you need any additional information or if anything is unclear.

import "./../style/visual.less"; import powerbi from "powerbi-visuals-api"; import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions; import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions; import IVisual = powerbi.extensibility.visual.IVisual; import DataView = powerbi.DataView; import DataViewValueColumn = powerbi.DataViewValueColumn; import DataViewCategorical = powerbi.DataViewCategorical; import DataViewCategoricalColumn = powerbi.DataViewCategoricalColumn; import DataViewCategoryColumn = powerbi.DataViewCategoryColumn; import PrimitiveValue = powerbi.PrimitiveValue; import IVisualHost = powerbi.extensibility.visual.IVisualHost; import IColorPalette = powerbi.extensibility.IColorPalette; import VisualObjectInstance = powerbi.VisualObjectInstance; import VisualObjectInstanceEnumeration = powerbi.VisualObjectInstanceEnumeration; import VisualObjectInstanceEnumerationObject = powerbi.VisualObjectInstanceEnumerationObject; import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions; import Fill = powerbi.Fill; import VisualTooltipDataItem = powerbi.extensibility.VisualTooltipDataItem; import ISelectionManager = powerbi.extensibility.ISelectionManager; import { valueFormatter as vf, textMeasurementService as tms } from "powerbi-visuals-utils-formattingutils"; import IValueFormatter = vf.IValueFormatter; import { VisualSettings,BarchartProperties } from "./settings"; import * as d3 from "d3"; type Selection<T extends d3.BaseType> = d3.Selection<T, any, any, any>; type DataSelection<T> = d3.Selection<d3.BaseType, T, any, any>; export interface BarchartDataPoint{ Category: string; Value: number; } export interface BarchartViewModel{ IsNotValid: boolean; DataPoints?:BarchartDataPoint[]; Format?: string, SortBySize?: boolean; XAxisFontSize?: number; YAxisFontSize?: number; BarColor?: string ColumnName?: string; MeasureName?: string; } export class Barchart implements IVisual { private svg: Selection<SVGElement>; private barContainer: Selection<SVGGElement>; private plotBackground: Selection<SVGRectElement>; private barSelection: DataSelection<BarchartDataPoint>; private xAxisContainer: Selection<SVGGElement>; private yAxisContainer: Selection<SVGGElement>; private barContainer2: Selection<SVGGElement>; private plotBackground2: Selection<SVGRectElement>; private barSelection2: DataSelection<BarchartDataPoint>; private xAxisContainer2: Selection<SVGGElement>; private yAxisContainer2: Selection<SVGGElement>; private hostService: IVisualHost; private settings: VisualSettings; private viewModel: BarchartViewModel; private static margin = { top:20, right: 20, bottom: 20, left: 50, }; constructor(options: VisualConstructorOptions) { console.log('Constructor executing', options); this.hostService = options.host; this.svg = d3.select(options.element) .append('svg') .classed('Barchart',true); this.barContainer = this.svg .append('g') .classed('barContainer', true); this.plotBackground = this.barContainer .append('rect') .classed('plotBackground', true); this.xAxisContainer = this.svg .append('g') .classed('xAxis', true); this.yAxisContainer = this.svg .append('g') .classed('yAxis', true); this.barContainer2 = this.svg .append('g') .classed('barContainer2', true); this.plotBackground2 = this.barContainer2 .append('rect') .classed('plotBackground2', true); this.xAxisContainer2 = this.svg .append('g') .classed('xAxis2', true); this.yAxisContainer2 = this.svg .append('g') .classed('yAxis2', true); this.settings = VisualSettings.getDefault() as VisualSettings; } public update(options: VisualUpdateOptions) { var viewModel: BarchartViewModel = this.createViewModel(options.dataViews[0]); if (viewModel.IsNotValid){ return; } //set height and width of root SVG element using viewport passed by Power BI host this.svg.attr("height",options.viewport.height); this.svg.attr("width", options.viewport.width); let marginLeft = Barchart.margin.left * (viewModel.YAxisFontSize / 10); let marginBottom = Barchart.margin.bottom * (viewModel.XAxisFontSize / 10); let marginTop = Barchart.margin.top; let marginRight = Barchart.margin.right; let plotArea = { x: marginLeft, y:marginTop, width: (options.viewport.width - (marginLeft + Barchart.margin.right))/2, height: (options.viewport.height - (marginTop + marginBottom)), }; let plotArea2 = { x: plotArea.x + plotArea.width + 0.3, y: marginTop, }; this.barContainer .attr("transform","translate(" + plotArea.x + "," + plotArea.y + ")") .attr("width",options.viewport.width) .attr("height", options.viewport.height); this.plotBackground .attr("width", plotArea.width) .attr("height", plotArea.height) .style("fill","blue"); this.barContainer2 .attr("transform", "translate(" + plotArea.x + "," + plotArea.y + ")") .attr("width", options.viewport.width) .attr("height", options.viewport.height); this.plotBackground2 .attr("width", plotArea.width) .attr("height", plotArea.height) .style("fill", "none"); var xScale = d3.scaleBand() .rangeRound([0, plotArea.width]) .padding(0.1) .domain(viewModel.DataPoints.map((dataPoint:BarchartDataPoint) => dataPoint.Category)); this.xAxisContainer .attr("class", "xAxis") .attr("transform","translate(" + plotArea.x + "," + (plotArea.height + plotArea.y)+")") .call(d3.axisBottom(xScale)); this.xAxisContainer2 .attr("class", "xAxis2") .attr("transform", "translate(" + plotArea.x + "," + (plotArea.height + plotArea.y) + ")") .call(d3.axisBottom(xScale)); d3.select(".xAxis").selectAll("text").style("font-size",viewModel.XAxisFontSize); d3.select(".xAxis2").selectAll("text").style("font-size", viewModel.XAxisFontSize); let maxValueY: number = d3.max(viewModel.DataPoints,(dataPoint:BarchartDataPoint) => +(dataPoint.Value)); var valueFormatter = vf.create({ format: viewModel.Format, value: maxValueY/100, cultureSelector: this.hostService.locale }); var yScale = d3.scaleLinear() .rangeRound([plotArea.height,0]) .domain([0,maxValueY * 1.02]); var yAxis = d3.axisLeft(yScale) .tickFormat((d) => valueFormatter.format(d)); // .tickPadding(12).ticks(5); this.yAxisContainer .attr("class","yAxis") .attr("transform", "translate(" + plotArea.x + "," + plotArea.y + ")") .call(yAxis); /* this.yAxisContainer2 .attr("class", "yAxis2") .attr("transform", "translate(" + plotArea2.x + "," + plotArea.y + ")") .call(yAxis); */ d3.select(".yAxis").selectAll("text").style("font-size",viewModel.YAxisFontSize); // d3.select(".yAxis2").selectAll("text").style("font-size", viewModel.YAxisFontSize); this.barSelection2 = this.barContainer2 .selectAll('.bar') .data(viewModel.DataPoints); this.barSelection = this.barContainer .selectAll('.bar') .data(viewModel.DataPoints); const barSelectionMerged = this.barSelection .enter() .append('rect') .merge(<any>this.barSelection) .classed('bar',true); const barSelectionMerged2 = this.barSelection2 .enter() .append('rect') .merge(<any>this.barSelection2) .classed('bar', true); barSelectionMerged .attr("x", (dataPoint: BarchartDataPoint) => xScale(dataPoint.Category)) .attr("y", (dataPoint: BarchartDataPoint) => yScale(Number(dataPoint.Value))) .attr("width", xScale.bandwidth()) .attr("height", (dataPoint: BarchartDataPoint) => (plotArea.height - yScale(Number(dataPoint.Value)))) .style("fill",(dataPoint:BarchartDataPoint) => viewModel.BarColor); barSelectionMerged2 .attr("x", (dataPoint: BarchartDataPoint) => xScale(dataPoint.Category) + xScale.bandwidth() / 4) .attr("y", (dataPoint: BarchartDataPoint) => yScale(Number(dataPoint.Value))) .attr("width", xScale.bandwidth() / 2) .attr("height", (dataPoint: BarchartDataPoint) => (plotArea.height - yScale(Number(dataPoint.Value)))) .style("fill", (dataPoint: BarchartDataPoint) => 'yellow') .style("fill-opacity", (dataPoint: BarchartDataPoint) => 1); this.barSelection .exit() .remove(); } public createViewModel(dataView: DataView): BarchartViewModel{ //handle case where categorical DataView is not valid if(typeof dataView === "undefined" || typeof dataView.categorical === "undefined" || typeof dataView.categorical.categories === "undefined" || typeof dataView.categorical.values === "undefined"){ return {IsNotValid: true}; } this.settings=VisualSettings.parse(dataView) as VisualSettings; var categoricalDataView: DataViewCategorical = dataView.categorical; var categoryColumn: DataViewCategoricalColumn = categoricalDataView.categories[0]; var categoryNames: PrimitiveValue[] = categoricalDataView.categories[0].values; var categoryValues: PrimitiveValue[] = categoricalDataView.values[0].values; var BarchartDataPoints: BarchartDataPoint[] = []; for(var i=0; i < categoryValues.length; i++){ //get category name and category value var category : string = <string>categoryNames[i]; var categoryValue: number = <number>categoryValues[i]; //add new data point to barchartDataPoints collection BarchartDataPoints.push({ Category: category, Value: categoryValue }); } //get formatting code for the field that is the measure var format: string = categoricalDataView.values[0].source.format //get persistent property values var SortBySize: boolean = this.settings.barchartProperties.sortBySize; var xAxisFontSize: number = this.settings.barchartProperties.xAxisFontSize; var yAxisFontSize: number = this.settings.barchartProperties.yAxisFontSize; var barColor: string = typeof (this.settings.barchartProperties.barColor) == "string"? this.settings.barchartProperties.barColor: this.settings.barchartProperties.barColor.solid.color; //sort dataset rows by measure value instead of cateogry value if(SortBySize){ BarchartDataPoints.sort((x,y) =>{return y.Value - x.Value}) } //return view model to upate method return{ IsNotValid: false, DataPoints: BarchartDataPoints, Format: format, SortBySize: SortBySize, BarColor: barColor, XAxisFontSize: xAxisFontSize, YAxisFontSize: yAxisFontSize, ColumnName: dataView.metadata.columns[1].displayName, MeasureName:dataView.metadata.columns[0].displayName }; } public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration { var visualObjects: VisualObjectInstanceEnumerationObject = <VisualObjectInstanceEnumerationObject>VisualSettings.enumerateObjectInstances(this.settings, options); visualObjects.instances[0].validValues = { xAxisFontSize:{numberRange:{min: 10, max:36}}, yAxisFontSize: { numberRange: { min: 10, max: 36 } }, }; return visualObjects } }

 


How to calculate count of IDs per Average Number of Hours bucket

$
0
0

I am very new to PBI and DAX in general so I'm sorry if this is obvious but I would really appreciate any detailed explanations. I have a table with PersonID and Average Number of Hours per Week in a table that looks like this: 

PersonIDAverage Number of Hours per Week
10040
20135
30232
44340
51240
64332

 

and I would like to make a table/graph to show this data 

 

Average Number of Hours Per WeekCount of PersonID
403
351
322

Re: Need to hover the mouse away in filter section to show the data filter

$
0
0

I am having the same problem with Power BI embedded. 

 

If I click on one of the filters (e.g., #2 or #3) in the example above, and don't move my mouse, the "loading" message is displayed and it takes longer than necessary to comlete the loading process and present the available filter values to be selected. 

 

If I click on one of the filters (e.g., #2 or #3) in the example above, and then immediately move my mouse away from the filters, the avaialble filter values will be displayed almost immediately...   

 

It seems like the "loading" message gets stuck unless you move your mouse somewhere else on the page... 

 

Anyone else seeing this problem with Power BI embedded? 

Re: Adding a Second Measure to Custom Visual

$
0
0

Hi ,

I can help you with this one - can you please attach your capabilities.json as well? This will specify how the second measure is getting added to the data view and I can make sure I provide you with the correct code.

Thanks,

Daniel

Re: Adding a Second Measure to Custom Visual

$
0
0

Thanks so much.  I was doing some more research on this and I think it has something to do with using for...in instead of bind...to.

 

Below is the capabilities JSON

{ "dataRoles": [ { "displayName": "Bar Grouping", "name": "myCategory", "kind": "Grouping" }, { "displayName": "Bar Measurement", "name": "myMeasure", "kind": "Measure" } ], "dataViewMappings": [ { "conditions": [ { "myCategory": { "max": 1 }, "myMeasure": { "max": 2 } } ], "categorical": { "categories": { "for": { "in": "myCategory" }, "dataReductionAlgorithm": { "top": {} } }, "values": { "select": [ { "bind": { "to": "myMeasure" } } ] } } } ], "objects": { "barchartProperties": { "displayName": "Barchart Properties", "properties": { "sortBySize": { "displayName": "Sort by Size", "type": { "bool": true } }, "barColor": { "displayName": "Bar Color", "type": { "fill": { "solid": { "color": true } } } }, "xAxisFontSize": { "displayName": "X Axis Font Size", "type": { "integer": true } }, "yAxisFontSize": { "displayName": "Y Axis Font Size", "type": { "integer": true } } } } } }

 

Re: How to calculate count of IDs per Average Number of Hours bucket

$
0
0

Hi ,

Welcome to learning Power BI and DAX!

I assume you're getting something like this when you try?

image.png

If so, Power BI is treating your Average Number of Hours per Week field as an implicit measure, because it's numeric.

You don't want to change this behaviour, as this is a good candidate for other calculations, but you can change this for the visual that you want to group it in.

In the fields list, click on the caret (down arrow) next to Average Number of Hours per Week and select Don't summarize, e.g.:

image.png

This will tell the visual to group by the unique values rather than aggregate them, and this should give you what you need, e.g.:

image.png

Hopefully this should be all you need to proceed.

Just to let you know, if you have any further questions specific to DAX, then it's generally better to post them in the DAX Commands and Tips forum, as it is a lot more heavily frequented than this developer forum and you'll get a much faster answer. The DAX folks don't look in here too often 😉

All the best,

Daniel


If my post solves your challenge, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂

Re: Adding a Second Measure to Custom Visual

$
0
0

Hi  - just getting your code set up and I'm getting some compilation errors due to my settings.ts not being in sync with the code in your visual.ts. Are you able to provide that too (sorry, I should have thought to ask for it orginally)?

One other question - is your visual intending to only display a maximum of two measures, and is the second measure performing a specific role (e.g. as a target vs the other measure)? This is important as it'll have an effect on how we build your view model and capabilties.json to suit.

Thanks,

Daniel

Re: How to calculate count of IDs per Average Number of Hours bucket

$
0
0

Hi   Thank you for replying! I'll take that advice and start looking in the other forum more than this one 🙂 

 

Your suggestion did not quite work for me. I think the issue is that my Average Hours by Week also is a calculated measure: 

 

APW2 =
AVERAGEX(
    KEEPFILTERS(VALUES('Table'[Date_wkOfYrNbr])),
    CALCULATE(SUM('Table'[M_Proj_Total_Hrs]))
)
 
When I select the down arrow for average hours, I don't see the same screen you are 
 
 
1.PNG

Re: Adding a Second Measure to Custom Visual

$
0
0

I really appreciate your help.

 

Below is the settings.ts file.

 

My goal with this chart is to compare to values across one or more categories.  For example comparing budgeted amounts to actual amounts for each sales region where the green bars are the budget and the yellow bars are the actuals.  So to answer your question more directly, each bar would be the sume of different measures (e.g. actual, budget).  I hope that makes sense.

 

"use strict"; import { dataViewObjectsParser } from "powerbi-visuals-utils-dataviewutils"; import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser; import powerbi from "powerbi-visuals-api"; import Fill = powerbi.Fill; export class VisualSettings extends DataViewObjectsParser { // public dataPoint: dataPointSettings = new dataPointSettings(); public barchartProperties: BarchartProperties = new BarchartProperties(); } export class BarchartProperties { sortBySize: boolean = true; xAxisFontSize: number = 10; yAxisFontSize: number = 10; barColor: Fill = { "solid": { "color": "#018a80" } }; // default color is teal }

 

Re: How to calculate count of IDs per Average Number of Hours bucket

$
0
0

Hi ,

Thanks for coming back. It's good to know whether you're working with a measure or a column - I assumed a column. You won't get the Don't summarize option with a measure as measures are always aggregations and can't work as a grouping like you want in this case.

The challenge you'll have here is that the measure is going to perform as an aggregation of the values for the current row context - without a suitable accompanying column/field in the visual to group by, you're likely to always get a scalar (single) value because there are no rows in the resulting dataset.

The fact that you're using KEEPFILTERS implies that you're wanting this measure to be dynamic based on filter context?

What you want is quite an advanced scenario (at least for me!) and I think it needs a wider audience for input. I would suggest cross-posting this question in the previously-linked DAX forum with as much info as possible and I'm optimistic they can help you  much faster than if the question remains open here.

Good luck!

Daniel

Re: Adding a Second Measure to Custom Visual

$
0
0

Hi .,

Thanks very much - I can get the code to compile now.

Looks like you're trying something like a bullet chart?

If so, I'd suggest creating specific data roles for each measure as they each have an intended purpose. This will make your code easier to manage rather than using a single data role with multiple measures and more intuitive to the end-user. Using the same data role with multiple measures will cause a challenge in that they will all have the same role type, processing the data view and assigning the measures to the appropriate bar will depend on the order they're added by the end user.

I'll proceed on the basis that we want two distinct measure roles - for the sake of illustration, I'll call them actual and budget and provide you with the changes required to make that work. Does that sounds like a good approach to you? If you want to stick with the existing approach, let me know and I'll provide you with a solution as per your requirements.

Thanks,

Daniel

Re: How to calculate count of IDs per Average Number of Hours bucket

$
0
0

Thanks  I think I managed to find myself to a solution. I ended up exporting the data from the measure I made which did result in a new table with a 1:1 relationship between ID and average hours worked, each of the values becoming implicit measures I believe. I played around enough to get the chart accurate, although there are a few outliers that proved to be true because of weird, but accurate data. Thanks for taking the time to help me out! This community seems really nice2.PNG

Re: Adding a Second Measure to Custom Visual

$
0
0

This sounds like a great approach.  And you are correct, it is similar to the bullet chart, but much simpler.

Viewing all 48159 articles
Browse latest View live


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