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

Select with SelectionManager by rows instead of by category

In my dataview I have a table where each row contains 3 columns. Is there a way for me to tell the Selection Manager to select the a specific row in the DataView? 

 

I've learned how to do it by category, which is quite simple and useful, but I'm at a loss on how to do it by rows from a given table in the DataView.

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-viig
Moderator

Re: Select with SelectionManager by rows instead of by category

To select data by row you should generate a SeletionId for each row by ushing this code:

 

/** This is TypeScript method */
private static getSelectionIds(dataView: DataView, host: IVisualHost): powerbi.visuals.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();
    });
}

After that, you will be able to use SelectionManager to select particular rows.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

2 REPLIES 2
Moderator v-viig
Moderator

Re: Select with SelectionManager by rows instead of by category

To select data by row you should generate a SeletionId for each row by ushing this code:

 

/** This is TypeScript method */
private static getSelectionIds(dataView: DataView, host: IVisualHost): powerbi.visuals.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();
    });
}

After that, you will be able to use SelectionManager to select particular rows.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

franky94 Frequent Visitor
Frequent Visitor

Re: Select with SelectionManager by rows instead of by category

Hi,  identity: DataViewScopeIdentity is not working anymore. Do you any suggestions ?

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 324 members 3,037 guests
Please welcome our newest community members: