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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ShivPB
Frequent Visitor

Calculate Cumulative Amount for Individual ID and Pickup the date at which amount exceeded the targe

Hello ,

 

I have query regarding cumulative sum.

My Problem Statement is : I have table in which I have Account Number , Overdue Date, Total Amount and many such columns. Same account number have multiple entries which have different overdue date or have another value for other columns. So I want to derive such a date whose occured cumulative sum is greater than 1,00,000. 

 

For eg:

 

Account NOOverdue DateAmountCumulative Sum
AY000118/3/20221000010000
AY0001110/4/20225000060000
AY0001128/5/202250000110000

 

In above table, I have account No : AY00011, which have different overdue dates and amounts. There is another column I need to calculate which is cumulative sum. Please share the logic for the same. And from that cumultaive sum I need to pickup the overdue date where cumulative sum for respective account is greater than 1 Lakh. In above case Cumulative Sum occurred greater than 1 Lakh at third row means we will pickup the date as "28/5/2022". 

 

It will be great help , if anyone share any ideas to solve the same.

2 ACCEPTED SOLUTIONS
v-yiruan-msft
Community Support
Community Support

Hi @ShivPB ,

I created a sample pbix file(see attachment), please check whether that is what you want.

Flag = 
VAR _target = 100000
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "@culvalue",
            CALCULATE (
                SUM ( 'Table'[Amount] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Account NO] = EARLIER ( 'Table'[Account NO] )
                        && 'Table'[Overdue Date] <= EARLIER ( 'Table'[Overdue Date] )
                )
            )
    )
VAR _mindate =
    MINX ( FILTER ( _tab, [@culvalue] > _target ), [Overdue Date] )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Overdue Date] ) = _mindate, 1, 0 )

Then apply visual-level filter with the condition(Flag is 1) as below screenshot:

yingyinr_2-1648182624058.png

Best Regards

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

View solution in original post

Thank you so much for the solution

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @ShivPB ,

I created a sample pbix file(see attachment), please check whether that is what you want.

Flag = 
VAR _target = 100000
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "@culvalue",
            CALCULATE (
                SUM ( 'Table'[Amount] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Account NO] = EARLIER ( 'Table'[Account NO] )
                        && 'Table'[Overdue Date] <= EARLIER ( 'Table'[Overdue Date] )
                )
            )
    )
VAR _mindate =
    MINX ( FILTER ( _tab, [@culvalue] > _target ), [Overdue Date] )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Overdue Date] ) = _mindate, 1, 0 )

Then apply visual-level filter with the condition(Flag is 1) as below screenshot:

yingyinr_2-1648182624058.png

Best Regards

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

Thank you so much for the solution

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.