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
SteveCnz
Advocate I
Advocate I

Calculate total $ customer invoice growth compared to last month only from growing customers

Hello, I thought this problem would be simple but has not been and no example I could find (Dax Patterns, EnterpriseDNA, PPPs love you all) seems to deal with this scenario.


We run a subscription business and invoice our customers once per month.

 

How do I calculate with DAX the total $ growth in customer invoicing this month compared to last month only for customers whose total invoicing this month is greater than their total last month? (This is easy on a customer by customer basis, but I want it on a total basis).  I have a standard total invoicing table with unique customer id linked to a calendar table by invoice date.

 

Any help would be much appreciated.

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @SteveCnz

 

Here's one way of doing it.

 

I'm going to assume you have a table called Invoices with columns Customer ID, Invoice Date, Amount.

As per your description, I'll assume Invoices[Invoice Date] is related to 'Calendar'[Date].

 

Then I would create the following measures (some of which you probably already have):

 

 

Invoice Amount =
SUM ( Invoices[Amount] )

Invoice Amount Month Ago =
CALCULATE (
    [Invoice Amount],
    DATEADD ( 'Calendar'[Month], -1, MONTH )
)

Invoice Amount Growth =
[Invoice Amount] - [Invoice Amount Month Ago]

Invoice Amount Growth Increases Only =
SUMX ( 
    VALUES ( Invoices[Customer ID] ),
    MAX ( BLANK(), [Invoice Amount Growth] )
)

The last measure iterates through Customers and sums the growth only for the Customers who have increased.

 

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

4 REPLIES 4
OwenAuger
Super User
Super User

Hi @SteveCnz

 

Here's one way of doing it.

 

I'm going to assume you have a table called Invoices with columns Customer ID, Invoice Date, Amount.

As per your description, I'll assume Invoices[Invoice Date] is related to 'Calendar'[Date].

 

Then I would create the following measures (some of which you probably already have):

 

 

Invoice Amount =
SUM ( Invoices[Amount] )

Invoice Amount Month Ago =
CALCULATE (
    [Invoice Amount],
    DATEADD ( 'Calendar'[Month], -1, MONTH )
)

Invoice Amount Growth =
[Invoice Amount] - [Invoice Amount Month Ago]

Invoice Amount Growth Increases Only =
SUMX ( 
    VALUES ( Invoices[Customer ID] ),
    MAX ( BLANK(), [Invoice Amount Growth] )
)

The last measure iterates through Customers and sums the growth only for the Customers who have increased.

 

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

I have use the same fomula  for downgrade  and its work for me but the problem I find that by using SumX(Values(Customer ID),Min(Blank(), [Invoice growth])) is I am not getting last month new users who did not pay invoice in current month.

 

 

Hi,

Does this measure work?

=SumX(CALCULATETABLE(Values(Customer ID),DATESBETWEEN(Calendar[Date],EDATE(MIN(Calendar[Date]),-1),MAX(Calendar[Date]))),Min(Blank(), [Invoice growth]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@shanipowerbi 

Ideally we should have a separate Customer dimension table to iterate over. This would ensure that all customers are considered whether or not they are present in the current filter context.

 

So the measure should be something like:

=
SUMX (
    VALUES ( Customer[Customer ID] ),
    MIN ( BLANK (), [Invoice growth] )
)

Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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.