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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic Histogram

Hello everyone,

 

I need to create a histogram graph using the followwing table.

The y axis must show the distinct count of codes.

The x axis must show the number of months that a code repeats, also i need the x-axis to be dynamic. For example, if i filter month = 1  and month = 3 that the graph only counts the selected codes.

 

MonthCode
13712
39476
211333
318679
218679
120709
220709
129570
229570
329667
229667
134088
336865
136865
236865
337635
141631
344680
145082
245082
145948
347994
247994
348762
248762
349813
249813
350299
150299
250299
350300
150300
250300
151191
251191
351191
351281
151281
353438
353920
154539
254539
354703
154703
254703
254877
354877
154877
158681
358681
358997
158997
258997
263316
363316
364180
167375
368015
276118
277187
180149
384423
391049
398200
3100974
2100974
3101165
2101165
2101607
3101607
3103539
1103539
2103539
3104469
2104469
1104534
3109243
1110777
2110777
3117756
1117756
2117756
1118641
2118641
2123189
1125201
2125561
3200397
2200397
3200447
1200447
2200447
2310451
1311772
1311779
1312960
2312960
1315453
2315493
3315493
1315493
1316130
1316222
3317674
2317674
3318260
1320431
1321047
3321047
1321318
3321700
2321700

 

The final solution should be as follows:

1.png

 

 

 

 

 

 

 

 

 

The example filtering with month = 1  and month = 3:

2.png

 

 

 

 

 

 

 

 

 

 

Best Regrads,

Mario Ortiz Lazo

2 ACCEPTED SOLUTIONS
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can create a calculated table uas the x-axis:

 

 

X-axis = 
GENERATESERIES (
    1,
    MAXX (
        SUMMARIZE ( ALL ( 'Table' ), [Code], "Count", COUNTROWS ( 'Table' ) ),
        [Count]
    ),
    1
)

 

 

Then we can create a measure to count the repeat code dymanicaly:

 

 

Total = 
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            GROUPBY ( 'Table', 'Table'[Code] ),
            "RepetCount", VAR c = [Code] RETURN CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Code] = c )
        ),
        [RepetCount] IN FILTERS ( 'X-axis'[Value] )
    )
)

 

 

14.PNG15.PNG

 


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

I could solve it!!!!

 

Thank you very much.

 

Best regrads,

Mario Ortiz Lazo

View solution in original post

3 REPLIES 3
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can create a calculated table uas the x-axis:

 

 

X-axis = 
GENERATESERIES (
    1,
    MAXX (
        SUMMARIZE ( ALL ( 'Table' ), [Code], "Count", COUNTROWS ( 'Table' ) ),
        [Count]
    ),
    1
)

 

 

Then we can create a measure to count the repeat code dymanicaly:

 

 

Total = 
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            GROUPBY ( 'Table', 'Table'[Code] ),
            "RepetCount", VAR c = [Code] RETURN CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Code] = c )
        ),
        [RepetCount] IN FILTERS ( 'X-axis'[Value] )
    )
)

 

 

14.PNG15.PNG

 


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the response.

 

I have an error message when i create the calculated table (x-axis) with the maxx function.

It seems that the calculated table can´t recognized the [count] column

 

MAXX ( SUMMARIZE ( ALL ( 'Table' ); [code]; "Count"; COUNTROWS ( 'Table' ) ); [Count])

 

Error message: The expression specified in the query is not a valid table expression.

Anonymous
Not applicable

I could solve it!!!!

 

Thank you very much.

 

Best regrads,

Mario Ortiz Lazo

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.