Forum Discussion

fab_incher's avatar
fab_incher
Frequent Visitor
3 years ago
Solved

Building a histogram based on a measure

Hi folks,   i'm trying to build a histogram with my individual defined x-Axis, based on a measure. The measure aggregates the elapsed time of different processing steps for finishing a single orde...
  • DataInsights's avatar
    3 years ago

    fab_incher,

     

    Try this measure. The issue is that you were using FILTER which iterates the table, resulting in counting steps (rows) instead of Order ID. The VALUES function returns a table of distinct Order ID in the filter context, and ADDCOLUMNS evaluates [Average_Order_Time_Needed_Minutes] in the context of each Order ID.

     

    HistogramCount_Measure = 
    VAR vTable =
        ADDCOLUMNS (
            VALUES ( Order_Processing[Order_ID] ),
            "@AvgOrdTime", [Average_Order_Time_Needed_Minutes]
        )
    VAR vResult =
        COUNTROWS (
            FILTER (
                vTable,
                [@AvgOrdTime] >= MIN ( 'Histogram_x-Axis'[Lower_Minutes] )
                    && [@AvgOrdTime] < MAX ( 'Histogram_x-Axis'[Upper_Minutes] )
            )
        )
    RETURN
        vResult