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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Rate
Helper III
Helper III

Quotas, Cummulative Sum and Remains

Hello all,

 

I am struggling with some calculations regarding quotas for clients.

 

I have a table with a list of clients and a maximum amount (quota) they can benefit from discounts. They can buy as much product as they want, but they have a limit to how much of said quantity will have a discount.

I have another table with the list of all the invoices issued to that Client, where I would want to add a column where I calculate the cummulative sum of the sales by date (650 in my example) and that, when the cummulative amount calculated is bigger than the quota assigned to that client (500), it returns the reminder of the quota left to that client at that date (50: calculated as the quota - cummulative sum from previous invoices).

 

I managed to calculate the cummulative sum but I can't get to make the formula look for the cummulative amount up to the date just before the last invoice.


I paste below the two tables I mentioned, with a column of desired output, as I am sure will help understand better the question.

 

Any ideas as to how I could calculate this remains on the last invoice?

 

Thank you very much in advanced!

 

Client IDMax Quota
1500

 

Invoice IDDateClient IDIncomeCummulative IncomeDesired Output
101/01/20201100100100
201/02/20201200300300
301/03/20201150450450
401/04/2020120065050
1 ACCEPTED SOLUTION
DataZoe
Microsoft Employee
Microsoft Employee

@Rate Oops! I am sorry, I was re-reading your post and realized I missed you wanted it to not take into account today's cumulative, but the earlier one. Try this measure to do that:

 

Cumulative with Quota Measure =
VAR _c_today = CALCULATE(
    sum( 'Table'[Income] ),
    filter(
        ALLSELECTED( 'Table'[Date] ),
        ISONORAFTER( 'Table'[Date], max( 'Table'[Date] ), DESC )
    )
) 
VAR _c_earlier = CALCULATE(
    sum( 'Table'[Income] ),
    filter(
        ALLSELECTED( 'Table'[Date] ),
        ISONORAFTER( 'Table'[Date], max( 'Table'[Date] ) -1, DESC )
    )
) 
VAR _q = sum( TableQuota[Max Quota] ) 
VAR _d = _c_today - _q 

return if( _d > 0, _q - _c_earlier, _c_today )

DataZoe_0-1600298430749.png

 

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

2 REPLIES 2
DataZoe
Microsoft Employee
Microsoft Employee

@Rate Please try this measure:

 

Cumulative with Quota Measure =
VAR _c = CALCULATE(
    sum( 'Table'[Income] ),
    filter(
        ALLSELECTED( 'Table'[Date] ),
        ISONORAFTER( 'Table'[Date], max( 'Table'[Date] ), DESC )
    )
) 
VAR _q = sum( TableQuota[Max Quota] ) 
VAR _d = _c - _q 

return if( _d > 0, _d, _c )

 

I wasn't sure if you had a Date table set up or not, so I used the same table date. You can change that to date table date too.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

DataZoe
Microsoft Employee
Microsoft Employee

@Rate Oops! I am sorry, I was re-reading your post and realized I missed you wanted it to not take into account today's cumulative, but the earlier one. Try this measure to do that:

 

Cumulative with Quota Measure =
VAR _c_today = CALCULATE(
    sum( 'Table'[Income] ),
    filter(
        ALLSELECTED( 'Table'[Date] ),
        ISONORAFTER( 'Table'[Date], max( 'Table'[Date] ), DESC )
    )
) 
VAR _c_earlier = CALCULATE(
    sum( 'Table'[Income] ),
    filter(
        ALLSELECTED( 'Table'[Date] ),
        ISONORAFTER( 'Table'[Date], max( 'Table'[Date] ) -1, DESC )
    )
) 
VAR _q = sum( TableQuota[Max Quota] ) 
VAR _d = _c_today - _q 

return if( _d > 0, _q - _c_earlier, _c_today )

DataZoe_0-1600298430749.png

 

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.