Forum Discussion

RichOB's avatar
RichOB
Icon for Post Partisan rankPost Partisan
1 year ago
Solved

Need help with Investment data calculations please!

I have a bit of a head-scratcher to get to a calculation for investment figures. Using the raw data in Table1, I need to create a Table2 2 in a matrix/table visual. I need:


- I do not have the Rolling_Amount column, that is there to show what I need. I need it to show the Rolling_Amount figure based on the accumulation of the previous month's Amounts.

    e.g April to July is 2900, April to August is 3400.

 

- A Calculation that gives the Monthly_Difference between the monthly Investment amount

   e.g May - April = 200. June - May = 1200.

 

- A calculation to get the Cash Movement, which is the Movement on Investments - Monthly_Difference.

  e.g May is 200 - 70. Cash_Movement Total for May is 130

 

Table 1   
CategoryPosting_DateAmountRolling_Amount
Investments30/04/2024600 
Investments31/05/2024200800
Investments31/06/202412002000
Investments30/07/20249002900
Investments31/08/20245003400
Investments30/09/2024-5002900
Investments31/10/20242003100
Investments30/11/20249804080
Investments31/12/20241004180
Movement on Investment30/04/202460 
Movement on Investment31/05/202470 
Movement on Investment31/06/202445 
Movement on Investment30/07/202430 
Movement on Investment31/08/202460 
Movement on Investment30/09/202465 
Movement on Investment31/10/202440 
Movement on Investment30/11/202420 
Movement on Investment31/12/202410 

 

Table2         
CategoryAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
Investments (Rolling_Amount)6008002000290034002900310040804180
Monthly Difference 2001200900500-500200980100
Movement on Investment607045306065402010
Cash Movement 1301155870440-43516096090

 

Thanks in advance for your help!

  • Make sure you have a date table, marked as a date table, linked to your Posting Date column in a one-to-many single direction relationship.

    You can then create measures like

    Rolling Amount =
    VAR MaxDate =
        MAX ( 'Date'[Date] )
    VAR Result =
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            'Date'[Date] <= MaxDate,
            'Table'[Category] = "Investments"
        )
    RETURN
        Result
    

    The monthly difference is just the sum of the amount column

    Monthly difference =
    CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Category] = "Investments" )
    

    and the cash movement would be

    Cash Movement =
    [Monthly Difference]
        - CALCULATE (
            SUM ( 'Table'[Amount] ),
            'Table'[Category] = "Movement on investment"
        )
    
  • Hi RichOB 

    Try this calc column

    Rolling Invesments = 
    IF (
        'Table'[Category] = "Investments",
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            FILTER (
                'Table',
                'Table'[Category] = "Investments"
                    && 'Table'[Posting_Date] <= EARLIER ( 'Table'[Posting_Date] )
            )
        )
    )
    

    But you can actually do this with measures

    What I dont get is for September, your cash movement is -435 when -500-65 = -565

     

    Please see the attached sample pbix for the details.

7 Replies

  • Hi RichOB Could you follow these 

    1. Use the existing Rolling_Amount column from Table1 in your matrix.

    2. Create a Monthly_Difference measure: CurrentMonth - PreviousMonth using the DATEADD function.

    3. Create a Cash_Movement measure: Monthly_Difference - Movement on Investment.

    4. Add a matrix visual with rows as Category, columns as months, and values as Rolling_Amount, Monthly_Difference, and Cash_Movement.

    • RichOB's avatar
      RichOB
      Icon for Post Partisan rankPost Partisan

      Hi Akash_Varuna I don't have an existing Rolling_Amount column from Table 1, that's what I need help with. Your other steps, 2,3 and 4 are doable after the Rolling_Amoutn column is created.

       

      Thanks

  • Make sure you have a date table, marked as a date table, linked to your Posting Date column in a one-to-many single direction relationship.

    You can then create measures like

    Rolling Amount =
    VAR MaxDate =
        MAX ( 'Date'[Date] )
    VAR Result =
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            'Date'[Date] <= MaxDate,
            'Table'[Category] = "Investments"
        )
    RETURN
        Result
    

    The monthly difference is just the sum of the amount column

    Monthly difference =
    CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Category] = "Investments" )
    

    and the cash movement would be

    Cash Movement =
    [Monthly Difference]
        - CALCULATE (
            SUM ( 'Table'[Amount] ),
            'Table'[Category] = "Movement on investment"
        )
    
  • Hi RichOB 

    Try this calc column

    Rolling Invesments = 
    IF (
        'Table'[Category] = "Investments",
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            FILTER (
                'Table',
                'Table'[Category] = "Investments"
                    && 'Table'[Posting_Date] <= EARLIER ( 'Table'[Posting_Date] )
            )
        )
    )
    

    But you can actually do this with measures

    What I dont get is for September, your cash movement is -435 when -500-65 = -565

     

    Please see the attached sample pbix for the details.

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi RichOB ,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Chaithra.

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi RichOB ,

    We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Chaithra.

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi RichOB ,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Chaithra.