Forum Discussion

gco's avatar
gco
Icon for Resolver II rankResolver II
6 years ago
Solved

Previous 15 day balance

Hi there,

 

I am trying to figure out how to get the beginning (15 days ago) and end balance for a specific table.

 

If i select DepositDate of 11/15/2019 from the slicer.  I would like to get the following:

 

EndBalance (123) = 61  -- (5+56) based on DepositDate

BeginningBalance(123) = 120   -- (55+65) based on ProcessDate = DepositDate - 15 days

BalanceType(A1 for 123) = 5 -- based on DepositDate

 

Same calculation for Account Number 345 

 

AccountNumberTypeBalanceDepositDateProcessDate
123A1511/15/201911/16/2019
123A25611/15/201911/16/2019
123A36510/25/201910/31/2019
123A45510/24/201910/31/2019
123A54510/30/201910/30/2019
345A15411/15/201911/30/2019
345A2510/1/201910/31/2019
345A34510/3/201910/30/2019

 

I tried the following measure for BeginningBalance but i am getting blank.

 

= CALCULATE (SUM(table[Balance]), FILTER(table,table[processdate] = SELECTEDVALUE(table[DepositDate])-15)

 

Your help is very much appreciated!

Thank you

Glen

  • Hi Glen,
    Here you go...PBIX 
    In the message it is right above my name.  The formatting in those messages leave something to be desired.
    Nathaniel

11 Replies

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

    Hi gco ,

     

    To create the measures as below.

    BalanceType(A1 for 123) = 
    VAR seld =
        SELECTEDVALUE ( 'Table 2'[Date] )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Balance] ),
            FILTER (
                'Table',
                'Table'[AccountNumber] = 123
                    && 'Table'[DepositDate] = seld
                    && 'Table'[Type] = "A1"
            )
        )
    
    BeginningBalance(123) = 
    VAR selpre15 =
        SELECTEDVALUE ( 'Table 2'[Date] ) - 15
    RETURN
        CALCULATE (
            SUM ( 'Table'[Balance] ),
            FILTER (
                'Table',
                'Table'[AccountNumber] = 123
                    && 'Table'[ProcessDate] = selpre15
            )
        )
    
    EndBalance (123) = 
    VAR seld =
        SELECTEDVALUE ( 'Table 2'[Date] )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Balance] ),
            FILTER ( 'Table', 'Table'[AccountNumber] = 123 && 'Table'[DepositDate] = seld )
        )
    

    For more details, please check the pbix as attached.

     

  • Nathaniel_C's avatar
    Nathaniel_C
    Icon for Community Champion rankCommunity Champion

    Hi gco ,

    Does this look like what you are after?

    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
    Nathaniel

     

    • gco's avatar
      gco
      Icon for Resolver II rankResolver II

      Hi Nathaniel_C ,

       

      Can you please tell me where i could download the pbix file?  I seem to be missing the download link.

      Thank you

      Glen

      • Nathaniel_C's avatar
        Nathaniel_C
        Icon for Community Champion rankCommunity Champion

        Hi Glen,
        Here you go...PBIX 
        In the message it is right above my name.  The formatting in those messages leave something to be desired.
        Nathaniel