Forum Discussion

RJF_iP's avatar
RJF_iP
New Member
3 years ago

Retention/Cohort Report DAX

Hi!

 

I need help creating a DAX for my retention rate report. The function I need is the unique count of customers for the "Order Year"divided by the unique count of customers from the prior order year. It seems like it should be pretty simple but I'm super new to this.

5 Replies

  • For reference, this is what the matrix containing the unique customer count looks like. The columns are order year and the rows are initial order year

     

    And these are the data set fields:

     

     

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, RJF_iP ;

    You could try it.

    Measure = 
    DIVIDE(DISTINCTCOUNT('Table'[ID]),
    CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),[Year]=MAX('Table'[Year])-1)))

    the final show:

    or 

    Measure = 
    DIVIDE(DISTINCTCOUNT('Table'[ID]),
    CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),[Year]=MAX('Table'[Year])-1&&YEAR([Date])=YEAR(MAX('Table'[Date])))))


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

     

    • RJF_iP's avatar
      RJF_iP
      New Member

      Thank you for this! The results aren't quite as expected, can you check the changes I made based on my data column names, please?

       

      These are the results I would expect to return:

       

      And this is what the formula above returned:

       

       

       

       

       

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, RJF_iP ;

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community


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