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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ana-pierola
Frequent Visitor

Custom visual with aggregated values

Hello!

 

I'm trying to create a custom Histogram visual. I need the custom visual to take a data measure and a category, calculate aggregated sums of the measure by the category, and draw a histogram of the aggregated sum values. All this needs to be compatible with an interactive date filter. My data table looks like this:

 

Date                    Category          Measure

2022-01-01        1

2022-01-01        2

...

2022-01-02        1

2022-01-02        2

...

 

I've tried adapting these two examples, but I have not achieved any good results:

https://github.com/microsoft/PowerBI-visuals-sampleBarChart

https://github.com/microsoft/powerbi-visuals-histogram

 

Can anybody give me a hint of how to do this?

Thanks!

 

2 REPLIES 2
ana-pierola
Frequent Visitor

Hi @dm-p 

 

Thanks a lot for your answer. That was really helpful! Actually, I can get the aggregation that I need with your Violin Plot visual.

 

Screenshot 2022-04-22 at 09.44.48.png

Screenshot 2022-04-22 at 09.45.02.png

 

Also, since it shows the distribution, it may be a good alternative to the Histogram that I need to develop.

 

However, if I still needed to create a Histogram, how should I define the data roles and data view mappings in order to have this aggregation? And how do I get the visual to use these calculated values instead of the input fields?

 

Thanks!

dm-p
Super User
Super User

Hi @ana-pierola,

For any visuals that need to calculate statistics over values and aggregate them, all underlying values need to be provided to the visual dataset so that they can be computed internally. Visuals are not able to know more about the model than what is supplied to the visual data roles and data view mapping (dataset).

In the case of a histogram, you will need to also supply a grouping column/field to your dataset that ensures each row is unique, such as an identify column, otherwise you will not be able to derive the correct values. Note that if you supply lots of data you may need to ensure that you can work with the row limits.

The Violin Plot visual uses this approach also, and I've written a post to explain thy this is necessary here, which may help you to understand how visuals need their data to be able to aggregate it themselves.

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)




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.