Print

Create a histogram using a DAX measure in Power BI

If you need to create a histogram out of the results of a measure, here is how to do it!

Watch the YouTube video

DAX Fridays #227: Histogram  of a measure (re-edit)

The code used

The DAX needed for the x-axis is:

Histogram = 
 VAR max_event = MAXX(VALUES('Events'[DeviceId]), [Events per device]) 
return
GENERATESERIES(1,max_event,1)

and for the y axis:

Histogram Events = 
VAR valuesToCount = 
FILTER(
    ADDCOLUMNS(
        SUMMARIZE('Events', 'Events'[DeviceId]),
        "events",[Events per device]
    ),
    [events] = SELECTEDVALUE('Histogram'[Value])
)
    
RETURN COUNTROWS(valuesToCount) 

Download the file

The demo file in in the download center, get file 272.

Related Resources

DAX Fridays! #95: Binning, Frequency and relative frequency | Data profiler
Was this helpful?

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents