Forum Discussion

obothewizard's avatar
obothewizard
Icon for Helper I rankHelper I
5 years ago
Solved

Bucketing average values from measure into bins/groups

Hi there,   I am trying to create a histogram based on the average days it take for a customer to make an order. I have already created a measure which gives me the average elapse in days per uniqu...
  • MFelix's avatar
    5 years ago

    Hi  obothewizard ,

     

    You are making the countrows of the orders levels, that means that you are not counting the number of customers but all the rowes in the orders tables. You need to summarized table with the customer ID and the averageX values and used it on your calculations something like this:

     

    Avg Days Dist Cust =
    IF (
        HASONEVALUE ( 'Order Elapse Table'[Min] ),
        COUNTROWS (
            FILTER (
                SUMMARIZE ( Order, Order[CustDI], "AVERAGEDAYS", [Average Days Between Orders] ),
                [AVERAGEDAYS] >= VALUES ( 'Order Elapse Table'[Min] )
                    && [AVERAGEDAYS] < VALUES ( 'Order Elapse Table'[Max] )
            )
        ),
        DISTINCTCOUNT ( Order[CustID] )
    )

     

    Be aware that this code is done by head just looking at your data, without further information about your data is difficult to pion point the error.

     

    If this does not work can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

    If the information is sensitive please share it trough private message.