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
Evandam
Helper II
Helper II

Calculate difference between invoice amount not based on date

I'm looking for a way to calculate the difference between invoice amount, but not based on dates (month), but based on order of the invoice. So the difference between each invoice per client based on the fact that the invoice number increases each time.

 

the sample data looks like this:

 

dummy data.jpg

1 ACCEPTED SOLUTION

pls try this

 

Column = 
VAR _l=maxx(FILTER('Table (2)','Table (2)'[client]=EARLIER('Table (2)'[client])&&'Table (2)'[invoice]<EARLIER('Table (2)'[invoice])),'Table (2)'[invoice])
return if(ISBLANK(_l),BLANK(),'Table (2)'[amount]-maxx(FILTER('Table (2)','Table (2)'[client]=EARLIER('Table (2)'[client])&&'Table (2)'[invoice]=_l),'Table (2)'[amount]))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
ryan_mayu
Super User
Super User

could you pls provide the expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




hi @ryan_mayu ,

it comes down to this:

result dummy.jpg

pls try this

 

Column = 
VAR _l=maxx(FILTER('Table (2)','Table (2)'[client]=EARLIER('Table (2)'[client])&&'Table (2)'[invoice]<EARLIER('Table (2)'[invoice])),'Table (2)'[invoice])
return if(ISBLANK(_l),BLANK(),'Table (2)'[amount]-maxx(FILTER('Table (2)','Table (2)'[client]=EARLIER('Table (2)'[client])&&'Table (2)'[invoice]=_l),'Table (2)'[amount]))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu 

Thank you! 
Almost works 100%. Only the last month of each years sums all the rows as you can see in the picture. Is there a way to fix this?

 

result1.jpg

yes , because you have more than one value for that month, what's the expected otuput?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




aaah sorry... its because i use the month and year in the X-axis so the values get summed in the vissual. thanks 🙂

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.