Forum Discussion

Kevin-Mann's avatar
Kevin-Mann
Icon for Advocate I rankAdvocate I
8 years ago
Solved

PRODUCTX is not working for Cumulative Return

I am trying to add the filtered return totals for each day and then use the DAX pattern to accumulate returns  (cumulative return).  I've tried several in-line variation of the below code, but nothing seems to function correctly except MINX/MAXX/SUMX.  I am working in DirectQuery mode.  The calculate table appears to force a summation and then add the 1 at the end.  Ultimately I want to use this measure in a "Line and Stacked Column" chart to view returns across varying dimentions.

 

Cumulative Return % = 
	VAR maxDate = MAX([Return Date])
	VAR minDate = MIN([Return Date])
	VAR DAILYSUM = CALCULATETABLE(SUMMARIZE(ALLSELECTED('Dates'), [Return Date], "Ret%", SUM('Exposure And Return'[Return %])), 'Exposure And Return'[Return Date] <= maxDate)   
    Return PRODUCTX(DAILYSUM, 1 + [Ret%]) - 1 

This produces the following results across a date range in June.  As you can see, the result is just a sum of the Return % line.

 

Return DateCumulative Return %Return %
6/1/20180.0350%0.0350%
6/4/20180.0375%0.0025%
6/5/2018-0.0124%-0.0499%
6/6/2018-0.0058%0.0066%
6/7/2018-0.1102%-0.1044%
6/8/2018-0.0473%0.0629%
6/11/20180.0220%0.0693%
6/12/20180.0570%0.0350%
6/13/20180.0806%0.0236%
6/14/20180.0462%-0.0344%
6/15/20180.0451%-0.0011%
6/18/20180.1033%0.0582%
6/19/20180.0430%-0.0602%
6/20/20180.0477%0.0047%
6/21/20180.0056%-0.0421%
6/22/20180.1037%0.0981%
6/25/20180.0626%-0.0411%
6/26/2018-0.0066%-0.0691%
6/27/20180.0342%0.0408%

 

Any help would be greatly appreciated!

  • Hi Kevin-Mann,

     

    It seems you need a number that could be the total of Return. But you didn't write it in the formula. How about the one like below?

    Cumulative Return % = 
    	VAR maxDate = MAX([Return Date])
    	VAR minDate = MIN([Return Date])
    	VAR DAILYSUM = CALCULATETABLE(SUMMARIZE(ALLSELECTED('Dates'), [Return Date], "Ret%", SUM('Exposure And Return'[Return %])), 'Exposure And Return'[Return Date] <= maxDate)   
        Return PRODUCTX(DAILYSUM, [Ret%] * [Return Amount]) 

     

    Best Regards,

    Dale

     

2 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Kevin-Mann,

     

    It seems you need a number that could be the total of Return. But you didn't write it in the formula. How about the one like below?

    Cumulative Return % = 
    	VAR maxDate = MAX([Return Date])
    	VAR minDate = MIN([Return Date])
    	VAR DAILYSUM = CALCULATETABLE(SUMMARIZE(ALLSELECTED('Dates'), [Return Date], "Ret%", SUM('Exposure And Return'[Return %])), 'Exposure And Return'[Return Date] <= maxDate)   
        Return PRODUCTX(DAILYSUM, [Ret%] * [Return Amount]) 

     

    Best Regards,

    Dale

     

    • Kevin-Mann's avatar
      Kevin-Mann
      Icon for Advocate I rankAdvocate I

      You know, I think my output was correct to begin with.  I'll give you credit anyhow.  Thanks!