Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
chotu27
Post Patron
Post Patron

How to Build SelectionID for table visual (Source Code)

Hi ,

 

Can you anyone let me know how to build selectionId in table visual or direct me to its Source code.

2 ACCEPTED SOLUTIONS

@v-viig Hi Ignat,

 

I already shared you my complete source code to your messages can you please check that and give me reply.

 

View solution in original post

v-viig
Community Champion
Community Champion

Hello @chotu27

 

Code has been updated. Please take a llok at the private message.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

9 REPLIES 9
v-viig
Community Champion
Community Champion

Please use this code as an example and current workaround:

getSelectionIds(dataView: DataView, host: IVisualHost): ISelectionId[] {
    return dataView.table.identity.map((identity: DataViewScopeIdentity) => {
        const categoryColumn: DataViewCategoryColumn = {
            source: dataView.table.columns[0],
            values: null,
            identity: [identity]
        };

        return host.createSelectionIdBuilder()
            .withCategory(categoryColumn, 0)
            .createSelectionId();
    });
}

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Hi Ignat

I tried to create selection id's with the workaround that you have sent. But its not working. The code just breaks at 

return host.createSelectionIdBuilder()
            .withCategory(categoryColumn, 0)
            .createSelectionId();
    });

statement giving no errors. I do not know how createSelectionIdBuilder is working. Please help 

v-viig
Community Champion
Community Champion

Hello @chotu27

 

Can you share source code? It that possible?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Hi @v-viig

I can share you apart of it. 

Here is the source code

 

Everything else seems to be working fine. It is only at that line where i am trying to create selection id's is what's not working.

//function for dataModelling
 public visualTransform(options: VisualUpdateOptions, host: IVisualHost):TableBarViewModel {
         let iValueFormatterPercent = ValueFormatter.create({ format: "0 %;-0%;0%" });   
         var dataViews =this.dataView = options.dataViews[0];
         let tableSelectionId: ISelectionId[] = this.getSelectionIds(dataViews,host);



//selection id function
public getSelectionIds(dataView: DataView, host: IVisualHost): ISelectionId[] {
 
return dataView.table.identity.map((identity: DataViewScopeIdentity) => {
const categoryColumn: DataViewCategoryColumn = {
source: dataView.table.columns[0],
values: null,
identity: [identity]
};
return host.createSelectionIdBuilder()
.withCategory(categoryColumn, 0)
.createSelectionId();
})
};


capabilities.json
"dataRoles": [
    {
      "displayName": "Values",
      "name": "values",
      "kind": "GroupingOrMeasure"
    }
  ],
  "dataViewMappings": [ 
    {    
      "conditions": [
        {
          "values": {
            "min": 1,
            "max": 25
          }
        }
      ],
       "table": {
          "rows": {
              "select": [{"for": { "in": "values" }}]
        }
    }
       }

  ],

 
v-viig
Community Champion
Community Champion

This code works well for me.

Are you sure that another part of the code works properly?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

@v-viig Hi Ignat,

 

I already shared you my complete source code to your messages can you please check that and give me reply.

 

v-viig
Community Champion
Community Champion

Hello @chotu27

 

Code has been updated. Please take a llok at the private message.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Anonymous
Not applicable

Hello,

 

Could you please share with me your code?

Hello,

 

I see that selection for table requires some hack.

Hopefully, a new API 2.5 which will be released next week contains .withTable method of the builder that must solve selection issues with Table mapping.

 

Kind Regards,

 

Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
pbicvsupport@microsoft.com

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors