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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

multi selection with AND operator

hi community

 

I have 2 selectionId,

1. select the city with value "Malang"

2. select the month with value "3"

 

this is the my code 

 

                let list : ISelectionId[] = [];
                list.push(this.model.dataPoints[0].selectionId); // city == Malang
                list.push(this.model.dataPoints[index].selectionId); // month == 3

                // console.log('sebelum', this.model.dataPoints[index].selectionId);
                // let includes = this.model.dataPoints[index].selectionId.includes(this.model.dataPoints[0].selectionId);
                // console.log('includes', includes);
                // console.log('hasil includes', this.model.dataPoints[index].selectionId);

                // ISQExpr.and

                selectionManager.select(list, true).then((ids: ISelectionId[]) => {
                    console.log('hasilnya', ids);
                });

 

but the result are "select all city with month == 3 or city == Malang"

 

how to make multiple selectionId with and operator?

the expected result only show month == 3 && city == Malang

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Anonymous,

I can't tell from your snippet how your selectionIds are generated, I believe you'll need to apply both columns to your ISelectionIdBuilder in order to generate one that intersects both categoricial values. 

Not sure if you've previously referred to this page, but it covers how you might chain the createSelectionId method with multiple values (for instance, .withCategory() and .withSeries()).

If you're not having much luck with this, perhaps you can share your capabilities.json and your view model mapping code? We can have a look and see if we can get a little further with it for you.

Regards,

Daniel





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

2 REPLIES 2
dm-p
Super User
Super User

Hi @Anonymous,

I can't tell from your snippet how your selectionIds are generated, I believe you'll need to apply both columns to your ISelectionIdBuilder in order to generate one that intersects both categoricial values. 

Not sure if you've previously referred to this page, but it covers how you might chain the createSelectionId method with multiple values (for instance, .withCategory() and .withSeries()).

If you're not having much luck with this, perhaps you can share your capabilities.json and your view model mapping code? We can have a look and see if we can get a little further with it for you.

Regards,

Daniel





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Anonymous
Not applicable

hi @dm-p 

 

I'm already solve this, the key is not how the manager to select but how the builder to create selectionId, right as your comment.

the hard way with matrix are how to create selectionId with row parents and columns parent.

 

this is my function with recursive children

if (x.values) {
                let keys = Object.keys(x.values);
                keys.forEach(k => {

                    let keyNum = Number(k);
                    let builder = host.createSelectionIdBuilder();

                    copyParents.forEach(p => {
                        builder.withMatrixNode(p, matrix.rows.levels);
                    });
                    
                    let colRef = columnsRef[keyNum];
                    colRef.nodes.forEach(p => {
                        builder.withMatrixNode(p, matrix.columns.levels);
                    });


                    let _td: DataListSelection = {
                        value: x.values[k],
                        selectionId: builder.createSelectionId(),
                    }
                    listSelectionPerRow.push(_td);

                });
            }

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.