Simplify Cumulative formula

sample 13_1.pbix (188.8 KB)

In the attached file, Final to Collect (4) is arrived after calculating 1,2,3 steps.
Is there anyway to simplify this calculation,
The basic logic is as below:

From the To Collect need to subtract Unapplied Receipts

Eg A :
In this case Unapplied Receipts < 2021 January To Collect (15 < 25 )
For 2021 January , Final To Collect =To Collect -Unapplied Receipts = 25-15 = 10
For 2021 February, Final To Collect= To Collect=3
For 2021 March, Final To Collect= To Collect=40

Eg B :
Suppose Unapplied Receipts was 30
In this case Unapplied Receipts > 2021 January To Collect (30 > 25 )
For 2021 January , Final To Collect =To Collect -Unapplied Receipts = 25-30= Since 30 is not fully subtractable from 25, 5 will be subtracted from 2021 February
therefore, for 2021 January ,Final To Collect = 0

For 2021 February, Final To Collect= To Collect -Unapplied Receipts=3 -5=
But since 5 is not fully subtractable from 3, 2 will be subtracted in March
therefore, for 2021 February, Final To Collect = 0

For 2021 March, Final To Collect= To Collect -Unapplied Receipts=40-2
Final To Collect = 40-2 = 38

For 2021 April, Final To Collect = To Collect …and so on…

My question is, to perform this logic, current I am performing steps 1,2, 3,4 as shown in the picture.
Is there any easier way of doing this?

Hi @Anu, we aim to consistently improve the topics being posted on the forum to help you in getting a strong solution faster. While waiting for a response, here are some tips so you can get the most out of the forum and other Enterprise DNA resources.

  • Use the forum search to discover if your query has been asked before by another member.
  • When posting a topic with formula make sure that it is correctly formatted to preformatted text </>.
    image
  • Use the proper category that best describes your topic
  • Provide as much context to a question as possible.
  • Include the masked demo pbix file and any other supporting links and details.

I also suggest that you check the forum guideline How To Use The Enterprise DNA Support Forum. Not adhering to it may sometimes cause delay in getting an answer.

Please also check the How To Mask Sensitive Data thread for some tips on how to mask your pbix file.

Hi @Anu

Based on your requirements provided, I have come up with below single Measure. Please check if this is helpful or any further help required.

It is calculating Cumulative Total for This month and Previous month. Based on the values, it is providing the output. I have also tested by adding 15 to your Unaplied Receipts and can see output as expected.

Total to Collect New =
VAR Cumm =  CALCULATE (SUM ( 'To Collect'[To Collect] ),
        FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ) )
VAR CummLM =  CALCULATE ( SUM ( 'To Collect'[To Collect] ),
        FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] < MIN ( ( 'Date'[Date] ) ) )    )
RETURN
    IF (
        ISBLANK ( cummlm ),
        IF (
            ISBLANK ( cumm ),
            BLANK (),
            IF ( cumm > [Unapplied Receipts], cumm - [Unapplied Receipts], 0 )
        ),
        IF (
            CummLM > [Unapplied Receipts],
            SUM ( 'To Collect'[To Collect] ),
            IF ( Cumm > [Unapplied Receipts], cumm - [Unapplied Receipts], 0 )
        )
    ) 

Note: It has multiple IF conditions based on requirements. You may add/remove as per the actual requirements.

Solution File attached EDNA_Solutions_Cumulative_Measure.pbix (190.3 KB)

Thanks
Ankit J

3 Likes

Will it be performance wise good as well than the above formula?

Hi @Anu - Don’t see any major performance issue with my measure . If you want to check the difference you can use “Performance Analyzer” in Desktop.

Hi @Anu - Please mark as solution, if response resolved your problem.

Thanks
Ankit J

Hi @Anu, we’ve noticed that no response has been received from you since the 22nd of January. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!