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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors