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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Husain
Advocate I
Advocate I

Selections for matrix data view mapping

Hi,

 

I am trying to create selections using SELECTION MANAGER for a custom visual which uses matrix data mapping but to no avail

 

Here are the relevant excerpts. Would be so grateful for your time and help

 

 constructor(options: VisualConstructorOptions) {
            this.selectionManager = options.host.createSelectionManager();
            this.selectionIdBuilder = options.host.createSelectionIdBuilder();
    }

public update(options: VisualUpdateOptions) {
        let dataViews = options.dataViews[0].matrix;
        if (!dataViews
            || !dataViews.rows
            || !dataViews.rows.root
            || !dataViews.rows.root.children
            || !dataViews.rows.root.children.length
            || !dataViews.columns
            || !dataViews.columns.root
            || !dataViews.columns.root.children
            || !dataViews.columns.root.children.length) { return }

  let root = d3.hierarchy(dataViews.rows.root)

 root.each(d => d.selectionId = this.selectionIdBuilder.withMatrixNode(d, dataViews.rows.levels)
              .createSelectionId())
console.log(root)

 here is dataview mapping from my Capabilities.json 

   "dataViewMappings": [
        {
            "matrix": {
                "rows": {
                    "for": {
                        "in": "Category"
                    }
                },
                "values": {
                    "select": [
                        {
                            "for": {
                                "in": "Measure"
                            }
                        }
                    ]
                }
            }
        }
    ]

 

Following is snap for my console. I get the selectionID property but it is same for all nodes(parent/child) and the key is null

 


selections.png

@dm-p 
@Nishantjain @Anonymous 

 

 

 

1 REPLY 1
Anonymous
Not applicable

try this https://community.powerbi.com/t5/Developer/multi-selection-with-AND-operator/m-p/781012#M20577

 

host.createSelectionIdBuilder();

make that code inside each looping

root.each(d => {
let builder = ... ; // create builder here
d.selectionId = builder.withMatrixNode(d, dataViews.rows.levels).createSelectionId();
})

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors