cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sreejith
Frequent Visitor

How to define Table DataViewMappings

Hi,

I want to make a custom visual with just two columns, one for text and other for a link button.

Ho can I define the dataview model.? I couldnot find any doc that defines a dataview for Table like one for Categorical

 

dataViewMappings: [{
                             categorical(Table?): {
                                            categories: {
                                                              for: { in: 'Category' },
                                                                          dataReductionAlgorithm: { top: {} }
                                                                        },
                                                             values: {
                                                           select: [{ bind: { to: 'Message' } }]
                                                                },
                                              }
                                  }],

 

How can I achieve this?

Thank you.

1 ACCEPTED SOLUTION
itayrom
Resolver II
Resolver II

Basically, if your dataRoles array is defined as follows:

 

dataRoles: [
	{
		displayName: 'Title',
		name: 'title',
		kind: powerbi.VisualDataRoleKind.Grouping
	},
	{
		displayName: 'Url',
		name: 'url',
		kind: powerbi.VisualDataRoleKind.Grouping
	}
]

Then your dataViewMappings array should look like this(I omitted the conditions[] array for clarity):

 

dataViewMappings: [{
    table: {
        rows: {
            select: [{for: { in: 'title' }},{for: { in: 'url' }}]
        }
    }
}]

The above will result in:

 

1. There will be two field wells displayed in Power BI, titled "Title" and "Url".

2. Your dataViews[index] object will have the following properties(among others...):

  • dataViews[index].table.columns[] array, which will contain that will contain some metadata about each column.
  • dataViews[index].table.rows[] array, which will contain arrays with values corresponding to the column indices.
  • dataViews[index].table.identities[] array, which will contain DataViewScopeIdentity objects corresponding to row numbers.
  • dataViews[index].table.identityFields[] array, which will contain the identityFields for each column.

Note that while the "columns" property is belongs to the table object, the other three are actually in its prototype.

 

A personal recommendation would be to log the dataView to the console and go through it yourself, and maybe play with the different mapping options. It's currently the best way I know to understand how these things work(Due to lack of documentation).

 

Also, note that you cannot have link buttons inside Power BI visuals. This is a security measure(called Sandboxing) taken by Microsoft, since it can be used to perform various malicious actions, such as Clickjacking and Cross-Site Scripting attacks, which is not something you want to be possible anywhere near your precious confidential corporate data.

View solution in original post

3 REPLIES 3
itayrom
Resolver II
Resolver II

Basically, if your dataRoles array is defined as follows:

 

dataRoles: [
	{
		displayName: 'Title',
		name: 'title',
		kind: powerbi.VisualDataRoleKind.Grouping
	},
	{
		displayName: 'Url',
		name: 'url',
		kind: powerbi.VisualDataRoleKind.Grouping
	}
]

Then your dataViewMappings array should look like this(I omitted the conditions[] array for clarity):

 

dataViewMappings: [{
    table: {
        rows: {
            select: [{for: { in: 'title' }},{for: { in: 'url' }}]
        }
    }
}]

The above will result in:

 

1. There will be two field wells displayed in Power BI, titled "Title" and "Url".

2. Your dataViews[index] object will have the following properties(among others...):

  • dataViews[index].table.columns[] array, which will contain that will contain some metadata about each column.
  • dataViews[index].table.rows[] array, which will contain arrays with values corresponding to the column indices.
  • dataViews[index].table.identities[] array, which will contain DataViewScopeIdentity objects corresponding to row numbers.
  • dataViews[index].table.identityFields[] array, which will contain the identityFields for each column.

Note that while the "columns" property is belongs to the table object, the other three are actually in its prototype.

 

A personal recommendation would be to log the dataView to the console and go through it yourself, and maybe play with the different mapping options. It's currently the best way I know to understand how these things work(Due to lack of documentation).

 

Also, note that you cannot have link buttons inside Power BI visuals. This is a security measure(called Sandboxing) taken by Microsoft, since it can be used to perform various malicious actions, such as Clickjacking and Cross-Site Scripting attacks, which is not something you want to be possible anywhere near your precious confidential corporate data.

View solution in original post

Greg_Deckler
Super User IV
Super User IV

I am not aware of a way to have a link button in a visual currently.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Greg_Deckler I could create a link button using SVG and on click it was redirecting.

  this.htmlContents = d3.select(options.element.get(0)).append("svg")

                              .attr("width",400)   

                            .attr("height", 200);

                           

                            this.htmlContents.append("a").attr("xlink:href", "http://en.wikipedia.org/wiki/")

                            .append("rect") 

                            .attr("x", 100)

                            .attr("y", 50)

                            .attr("height", 100)

                            .attr("width", 200)

                            .style("fill", "lightgreen")

                            .attr("rx", 10)

                            .attr("ry", 10);

                           

                           this.htmlContents.append("text")

                            .attr("x", 200)

                            .attr("y", 100)

                            .style("fill", "black")

                            .style("font-size", "20px")

                            .attr("dy", ".35em")

                            .attr("text-anchor", "middle")

                            .style("pointer-events", "none")

                            .text("Resolve");

But when I added the same to a table cell, errror occurs "Refused to display "https://app/powerbi.com/www/wiki.org" in a frame because it set X-Frame-Opttions to deny

XFrame error.png"

 

 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.