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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
israelovg
New Member

Custom Visual - How to get measure aggregation type

Hey guys,

 

I'm writing a custom matrix visual . The dataview has a matrix , when I get measures data(Values) , I need to know what type of aggregation measure is (sum, count , average , min ,max ).

 

How can I get measure aggregation type programmatically?

 

Here is my capabilities.json

{
        "dataRoles": [
            {
                "displayName": "Rows",
                "name": "rows",
                "kind": "Grouping"
            },
            {
                "displayName": "Columns",
                "name": "columns",
                "kind": "Grouping"
            },
            {
                "displayName": "Filters",
                "name": "filters",
                "kind": "Grouping"
            },
            {
                "displayName": "Values",
                "name": "measure",
                "kind": "Measure"
            }
        ],
        "dataViewMappings": [
            {
                "conditions": [
                    {
                        "rows": {
                            "max": 0
                        },
                        "columns": {
                            "max": 0
                        },
                        "measure": {
                            "min": 1
                        }
                    },
                    {
                        "rows": {
                            "min": 1
                        },
                        "columns": {
                            "min": 0
                        },
                        "measure": {
                            "min": 0
                        }
                    },
                    {
                        "rows": {
                            "min": 0
                        },
                        "columns": {
                            "min": 1
                        },
                        "measure": {
                            "min": 0
                        }
                    }
                ],
                "matrix": {
                    "rows": {
                        "select": [
                            {
                                "for": {
                                    "in": "rows"
                                }
                            },
                            {
                                "for": {
                                    "in": "filters"
                                }
                            }
                        ],
                        "dataReductionAlgorithm": {
                            "top": {
                                "count": 30000
                            }
                        }
                    },
                    "columns": {
                        "for": {
                            "in": "columns"
                        },
                        "dataReductionAlgorithm": {
                            "top": {
                                "count": 10000
                            }
                        }
                    },
                    "values": {
                        "select": [
                            {
                                "bind": {
                                    "to": "measure"
                                }
                            }
                        ]
                    }
                }
            }
        ],
        "objects": {
            "total": {
                "displayName": "Show Total",
                "properties": {
                    "columnTotal": {
                        "displayName": "Column",
                        "type": {
                            "bool": true
                        }
                    },
                    "rowTotal": {
                        "displayName": "Row",
                        "type": {
                            "bool": true
                        }
                    },
                    "columnGrandTotal": {
                        "displayName": "Grand Column",
                        "type": {
                            "bool": true
                        }
                    },
                    "rowGrandTotal": {
                        "displayName": "Grand Row",
                        "type": {
                            "bool": true
                        }
                    }
                }
            }
        }
    }
5 REPLIES 5
v-dancos
Microsoft Employee
Microsoft Employee

Is there any update on how to get measure aggregation type?

v-viig
Community Champion
Community Champion

You can try using the solution described in my previous comments.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

v-viig
Community Champion
Community Champion

There's not good way to detect type but you might try to detect type by displayName.

 

image.png

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

I 'm trying to calculate matrix measure  totals/subtotals (sum,count,average,min,max) .

Is there a way configure my capabilities.json that will bring matrix measure  subtotals for row/column items?

 

Thanks in Advance .

v-viig
Community Champion
Community Champion

No, subtotals are not supported yet. This feature is on our backlog (no ETA).

 

Just one more note, If you calculate totals in JS they might be a bit wrong as Power BI does not allow to get more than 1000 rows by default. This value can be configure via dataReductionAlgorithm but it can't be greater than 30000.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.