cancel
Showing results for 
Search instead for 
Did you mean: 
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!


My course: Introduction to Developing Power BI Visuals


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!


My course: Introduction to Developing Power BI Visuals


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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.