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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
saviourofdp
Frequent Visitor

Does anyone have a working example of the Customized data reduction capabilities in a matrix?

Hi all

 

I'm trying to set this up for a matrix visual following the documentation here: Customized data reduction but I can't seem to get it to work. I've updated my project to use API 5.2 and I've updated the capabilites file with the exact code from that page but the properties don't appear in the format pane. Does anyone have an example of this working?

 

Thanks

4 REPLIES 4
saviourofdp
Frequent Visitor

thanks for the reply @dm-p . Was your example purely capabilities.json changes or did you have to change anything in settings.ts, enumerateObjectInstances or the new formattingModel API?

Hi @saviourofdp,

I had to add a suitable class and properties to my visual settings that correspond to the capabilities (as has always been the way), otherwise these properties are not accessible to your VisualSettings class (or whatever name you have chosen for it). If your enumerateObjectInstances method has standard logic to populate the pane and you're not overriding your own containers too heavily, then there shouldn't be anything you need to do. However if you are doing this then it's going to depend on how you're building them.

If you're using the new formatting model (cards) that were  introduced in API 5.1, you still need to add settings classes and properties - and the revised guide to the formatting pane still includes this step if you need to confirm what this should look like - but you won't need to use enumerateObjectInstances if using the new pane; I believe the new powerbi-visuals-utils-formattingmodel package takes care of that if you're using them. If not, then you will need to set up your own overridden getFormattingModel method in the Visual class that has your logic to return a valid FormattingModel.

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)




Thanks for your help @dm-p . I've found that for a matrix to work, the relevant sections in the capabilities file needs to look like the following. In particular, the row algorithm needs to be set as window and columns algorithm needs to be set as something other than window. Otherwise, I see an error.

 

 

 

 

{
    "dataRoles": [
        {
            "displayName": "Row Data",
            "name": "rows",
            "kind": "Grouping"
        },
        {
            "displayName": "Column Data",
            "name": "columns",
            "kind": "Grouping"
        },
        {
            "displayName": "Measure Data",
            "name": "values",
            "kind": "Measure"
        }
    ],
    "objects": {
        "dataReductionCustomization": {
            "properties": {
                "columnCount": {
                    "type": {
                        "numeric": true
                    }
                },
                "rowCount": {
                    "type": {
                        "numeric": true
                    }
                }
            }
        }
    },
    "privileges": [],
    "dataViewMappings": [
        {
            "matrix": {
                "dataVolume": 6,
                "rows": {
                    "for": {
                        "in": "rows"
                    },
                    "dataReductionAlgorithm": {
                        "window": {
                            "count": 10
                        }
                    }
                },
                "columns": {
                    "for": {
                        "in": "columns"
                    },
                    "dataReductionAlgorithm": {
                        "sample": {
                            "count": 10
                        }
                    }
                },
                "values": {
                    "select": [
                        {
                            "for": {
                                "in": "values"
                            }
                        }
                    ]
                }
            }
        }
    ],
    "dataReductionCustomization": {
        "matrix": {
            "columnCount": {
                "defaultValue": 100,
                "propertyIdentifier": {
                    "objectName": "dataReductionCustomization",
                    "propertyName": "columnCount"
                }
            },
            "rowCount": {
                "defaultValue": 100,
                "propertyIdentifier": {
                    "objectName": "dataReductionCustomization",
                    "propertyName": "rowCount"
                }
            }
        }
    }
}

 

 

 

 

dm-p
Super User
Super User

Hi @saviourofdp,

I have looked into it a little bit when it released and I found that I had to have my objects and properties named exactly as per the example, i.e. my object had to be named dataReductionCustomization, and (as I was using a categorical mapping), I had to name my property categoryCount (as per the schema definition here).

For instance, I was trying to add these to an existing object with a different name in my capabilities.json, and it wouldn't work, despite me updating the root dataReductionCustomization object to point to this revised object and property. Not sure if that's something you might have done?

This hard-coding of names wasn't acceptable for me, as I wanted to consolidate my properties, so I didn't keep my example, unfortunately, but it did work when everything was named as per the documentation.

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)




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors