cancel
Showing results for
Did you mean:
Helper I

## 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:

1 ACCEPTED SOLUTION
Super User

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]))``````

Proud to be a Super User!

7 REPLIES 7
Super User

could you pls provide the expected output?

Proud to be a Super User!

Helper I

hi @ryan_mayu ,

it comes down to this:

Super User

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]))``````

Proud to be a Super User!

Helper I

@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?

Super User

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

Proud to be a Super User!

Helper I

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

Super User

you are welcome

Proud to be a Super User!

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors