Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Wendeley-North
Resolver I
Resolver I

Cumulative Product for last X months - based on Date From Separate Table

Hi, I've currently two tables that I need to put together, joined by a common Date table. For each date selected by TableFE, create various measures that take the cumulative product of the column [ReturnsNorm] for 1M, 3M and 6M lookback.

TableFE (Simplified to only have one date)

DateSlicerGroup1SlicerGroup2ParentGroupGroupValue
08-Jun-21SG1_1SG2_1PG1PG1_G10.340
08-Jun-21SG1_1SG2_1PG1PG1_G20.030
08-Jun-21SG1_1SG2_1PG2PG2_G1-0.388
08-Jun-21SG1_1SG2_1PG2PG2_G2-0.430

TableFR

DateSlicerGroup1ParentGroupGroupReturnReturnsNorm
29-Jan-21SG1_1PG_2PG2_G10.00481.0048
26-Feb-21SG1_1PG_2PG2_G1-0.00690.9931
31-Mar-21SG1_1PG_2PG2_G1-0.00310.9969
30-Apr-21SG1_1PG_2PG2_G1-0.00300.9970
31-May-21SG1_1PG_2PG2_G1-0.02670.9733
29-Jan-21SG1_1PG_2PG2_G20.00201.0020
26-Feb-21SG1_1PG_2PG2_G2-0.00560.9944
31-Mar-21SG1_1PG_2PG2_G20.00521.0052
30-Apr-21SG1_1PG_2PG2_G2-0.00100.9990
31-May-21SG1_1PG_2PG2_G20.02141.0214
29-Jan-21SG1_1PG_1PG1_G20.00031.0003
26-Feb-21SG1_1PG_1PG1_G20.00351.0035
31-Mar-21SG1_1PG_1PG1_G2-0.00300.9970
30-Apr-21SG1_1PG_1PG1_G2-0.00240.9976
31-May-21SG1_1PG_1PG1_G2-0.01000.9900
29-Jan-21SG1_1PG_1PG1_G10.00021.0002
26-Feb-21SG1_1PG_1PG1_G1-0.00590.9941
31-Mar-21SG1_1PG_1PG1_G1-0.00020.9998
30-Apr-21SG1_1PG_1PG1_G1-0.00280.9972
31-May-21SG1_1PG_1PG1_G10.00181.0018

Table Relationship

Wendeley-North_0-1623542967299.png

Desired Results

Applicable Slicers: Date (8 June 21 Selected), SlicerGroup1 selected

For the 6M lookback, since the provided sample data has only 5 months of data, the cumulative product is as such.

GroupValue1M Lookback3M Lookback6M Lookback
PG1_G10.3401.00180.99880.9931
PG1_G20.0300.99000.98470.9884
PG2_G1-0.3880.97330.96740.9653
PG2_G2-0.4301.02141.02571.0220

Attempted Code

1M_date = 
VAR endDate = EOMONTH( LASTDATE(TableFE[Date]), -1 ) -- Determined by slicer
VAR startDate = EOMONTH( LASTDATE(TableFE[Date]), -1 )
-- VAR startDate = DATE( YEAR(endDate), MONTH(endDate) - 1, DAY(endDate) ) -- 3-month lookback
VAR filteredTable = 
    FILTER( 
        ALLEXCEPT( TableFR, TableFR[Group] ), 
        TableFR[Date] >= startDate &&
        TableFR[Date] <= endDate 
        )
VAR t1 =
    SUMMARIZE( filteredTable, TableFR[Factor], "CumRet", PRODUCT( TableFR[ReturnsNorm] ) )
RETURN 
    [CumRet]

Which doesn't work because returning columns doesn't work like that. 

Appreciate any help, thanks. 

4 REPLIES 4
Kumail
Post Prodigy
Post Prodigy

Hello @Wendeley-North 

 

If you could send sample .pbix that demonstrate what you are looking to get. It would really help providing you a quick solution.

 

You can send the sample .pbix file by adding it to your drive or dropbox and add the link here.

 

Regards
Kumail Raza

Anonymous
Not applicable

Hi @Wendeley-North 

Has your problem been solved ? If it has been solved, provide your method for the problem then consider Accept it as the solution to help the other members find it more quickly.

If no , please answer my previous doubts, and then we will continue to deal with this issue .

 

Best Regards

Community Support Team _ Ailsa Tao

 

Anonymous
Not applicable

Hi @Wendeley-North 

I have a little doubt about the Desired Results you provided .

For PG1_G1 , The data for the previous month, 3 months, and 6 months are 1.0018, 0.9988, and 0.9931 respectively , meet the expectations you want .

But for the remaining 3 groups, the values of the first three months do not match what you expected, so what are your calculation rules for the values of the first 3 months and the first 6 months? Please confirm the results you need, and if possible, provide your sample. This will make it easier for us to deal with the problem better .

Actual results:

Ailsa-msft_0-1623747382273.pngAilsa-msft_1-1623747382275.png

Desired Results

Ailsa-msft_2-1623747382277.png

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Wendeley-North
Resolver I
Resolver I

Bump

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.