Forum Discussion

henryvu93's avatar
henryvu93
Helper I
8 years ago
Solved

Problem with Calculated Column

Hi guys,

 

I have a table with the sample like this: 

 

DateCustomer
1/1/2015A
1/1/2015B
1/1/2015C
1/1/2015D
1/1/2015E
1/1/2015F
1/1/2015G
1/1/2015H
2/1/2015A
2/1/2015B
2/1/2015D
2/1/2015E
2/1/2015F
2/1/2015C
2/1/2015I
2/1/2015J
2/1/2015K
2/1/2015L
2/1/2015M
2/1/2015N
3/1/2015A
3/1/2015B
3/1/2015C
3/1/2015E
3/1/2015D
3/1/2015F
3/1/2015G
3/1/2015H
3/1/2015I
3/1/2015J
4/1/2015A
4/1/2015B
4/1/2015C
4/1/2015D
4/1/2015E
4/1/2015F

 

I wanted to create a calculated column with this formula:

 

"Prev12Members = CALCULATE(DISTINCTCOUNT(Table[Customer]), SAMEPERIODLASTYEAR(Table[Date]))" 

However, it does not result in any values. It worked when I tried creating a measure and created a table (Visualization) with Date & this measure. Just wonder if it is possible to create calculated column as mentioned? Any insight will be greatly appreciated! Thanks!

 

 Regards,

Henry

 

 

  • Hi,

     

    Try this formula

     

    =CALCULATE( AVERAGEX(VALUES(Customer[Date]), [Churn Rate]), DATESBETWEEN ( Customer[Date], EDATE(MIN(Customer[Date]),-11),MAX(Customer[Date])))

     

    Hope this helps.

13 Replies

  • Hi,

     

    That will not work as a calculated column - it will only work as a measure.  But if the measure is already working for you, why do you want to write that as a calculated column?

    • henryvu93's avatar
      henryvu93
      Helper I

      Hi Ashish_Mathur,

       

      Thanks for your reply. Actually after this step, I want to summarize the table into a new table with date & the measure. However, with the measure "Prev12Members", my table did not show anything. I am thinking if I can create a column and summarize the table based on that column it might be possible.

       

      Regards,

      Henry

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

         

        Please describeyour entire question and show the expected result.