Forum Discussion

kcantor's avatar
kcantor
Community Champion
10 years ago
Solved

DAX Question : Average Days between purchases

Time for the (now famous) middle of the week DAX phone a friend question! (Dates Styme me) I have a sales table (Sales Performance) that uses line level records and contains customer numbers, Sales ...
  • kcantor's avatar
    kcantor
    10 years ago

    My averages seemed a little high so I decided to use the Median instead. Unfortunately, My powerpivot did not support it as DAX so I created this little gem:

    (MINX (FILTER ( VALUES ( Customer[Days between] ),
    CALCULATE (
    COUNT ( Customer[Days between] ), Customer[Days between] <= EARLIER ( Customer[Days between] ) )
    > COUNT ( Customer[Days between] ) / 2 ), Customer[Days between])
    + MINX ( FILTER ( VALUES ( Customer[Days between] ),
    CALCULATE (
    COUNT ( Customer[Days between] ), Customer[Days between] <= EARLIER ( Customer[Days between] ))
    > ( COUNT ( Customer[Days between] ) - 1 ) / 2 ), Customer[Days between])) / 2

     

    I am posting this in hopes of helping someone else as I have now created my own very cumbersome answer.  Maybe a shorter answer will present it self but for now I feel like my microphone is off.

    (tap tap tap)"Is this thing on?"