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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
edavis248
Helper I
Helper I

Remaining value count

Hi all-

 

I have contract values for the same contracts. The contract value shows the same value over and over as it is the same contract for each invoice. I need to create a column that takes the invoice amount minus the contract amount but that will put the nex value in the next row. Baiscally, I want to show the paid off amount getting smaller and smaller as each invoice is paid to the contact, eveutally beign 0$. 

 

Contract IDContract amountInvoice amountInvoice amount remainingWhat I want to show(remaining)
1100257575
1100257550
1100257525
110025750
1 ACCEPTED SOLUTION

Hi @edavis248 ,

 

Do you mean that when this column "What I want to show (remaining)" is negative, it also outputs 0? If yes, we can create a column.

What I want to show(remaining) = 
var a= CALCULATE(SUM('BGE_INVOICES'[Contract amount]),FILTER('BGE_INVOICES','BGE_INVOICES'[Index]=1))
var b=SUMX(FILTER('BGE_INVOICES','BGE_INVOICES'[Contract ID]=EARLIER('BGE_INVOICES'[Contract ID])&&'BGE_INVOICES'[Index]<=EARLIER('BGE_INVOICES'[Index])),'BGE_INVOICES'[Invoice amount])
return 
IF((a-b)>=0,(a-b),0)

I don't think I'm very clear about your new needs, my suggestion is that you mark the answer to the current post as a solution and recreate the post to describe the other needs in detail, thank you for your time.

 

Best Regards,

Neeko Tang

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

6 REPLIES 6
v-tangjie-msft
Community Support
Community Support

Hi @edavis248 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2)Click "Transform Data" to enter the Power Query editor and add an index column.

Picture1.png

(3) We can create a calculated column.

What I want to show(remaining) = 
var a= CALCULATE(SUM('Table'[Contract amount]),FILTER('Table','Table'[Index]=1))
var b=SUMX(FILTER('Table','Table'[Contract ID]=EARLIER('Table'[Contract ID])&&'Table'[Index]<=EARLIER('Table'[Index])),'Table'[Invoice amount])
return 
a-b

(4) Then the result is as follows.

vtangjiemsft_0-1675911272964.png

Best Regards,

Neeko Tang

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

Thanks Neeko I think this is what I need. However is there a reason my EARLIER function wont pull in the column? 

edavis248_0-1675976004075.png

 

Hi @edavis248 ,

 

Do you mean that when this column "What I want to show (remaining)" is negative, it also outputs 0? If yes, we can create a column.

What I want to show(remaining) = 
var a= CALCULATE(SUM('BGE_INVOICES'[Contract amount]),FILTER('BGE_INVOICES','BGE_INVOICES'[Index]=1))
var b=SUMX(FILTER('BGE_INVOICES','BGE_INVOICES'[Contract ID]=EARLIER('BGE_INVOICES'[Contract ID])&&'BGE_INVOICES'[Index]<=EARLIER('BGE_INVOICES'[Index])),'BGE_INVOICES'[Invoice amount])
return 
IF((a-b)>=0,(a-b),0)

I don't think I'm very clear about your new needs, my suggestion is that you mark the answer to the current post as a solution and recreate the post to describe the other needs in detail, thank you for your time.

 

Best Regards,

Neeko Tang

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

I actually added at a column not the measure so it worked technically. But it is showing some mass negative values. I have quiet a bit more contracts than my example. I am getting this result:

Appreciate any help I can work to get a workign file without sentitive info.

 

In the below I would expect the "Column" to show wha tthe inv amt remaining column does but trickle down to $0. currently I have the contract total - invoice amount of each invoice but was that value for 10/15/2021 to start the next line then $140,491 - 3,817(invoice amount) then the next line would be $136,674. Appreciate any help, I have been working on this for weeks. 

edavis248_0-1676039751451.png

 

 

Hi @edavis248 ,

 

Please click "New Column" in the "Modeling" pane and copy the following dax.

What I want to show(remaining) = 
var a= CALCULATE(SUM('BGE_INVOICES'[Contract amount]),FILTER('BGE_INVOICES','BGE_INVOICES'[Index]=1))
var b=SUMX(FILTER('BGE_INVOICES','BGE_INVOICES'[Contract ID]=EARLIER('BGE_INVOICES'[Contract ID])&&'BGE_INVOICES'[Index]<=EARLIER('BGE_INVOICES'[Index])),'BGE_INVOICES'[Invoice amount])
return 
a-b

Picture1.png

Best Regards,

Neeko Tang

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

I actually added at a column not the measure so it worked technically. But it is showing some mass negative values. I have quiet a bit more contracts than my example. I am getting this result:

Appreciate any help I can work to get a workign file without sentitive info.

 

In the below I would expect the "Column" to show wha tthe inv amt remaining column does but trickle down to $0. currently I have the contract total - invoice amount of each invoice but was that value for 10/15/2021 to start the next line then $140,491 - 3,817(invoice amount) then the next line would be $136,674. Appreciate any help, I have been working on this for weeks. 

edavis248_0-1675991763997.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.