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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Kristian_nho
Frequent Visitor

Count customers with 0 sales in the past 6 months

Hello,

 

I would like to calculate the number of customers per month with 0 sales value in the last 6 months.

My PBI model consists of 2 tables: SalesInvoice fact table and Customer dim table connected via a CustomerID.

Kristian_nho_0-1651860977726.png

 

.. I would like to write a DAX measure that would look something like:

=CALCULATE(

DISTINCTCOUNT('Customer DIM'[Customer Number]),

FILTER('Sales Invoice FACT', 'Sales Invoice FACT'[GSV_AccountingCurrency]=0) (in the last 6 months))

 

I have tried using a number of suggestions with CALCULATETABLE and FILTER but I either got a blank value or the filter did not work and I got the total number of customers per month.

 

Please help.

 

Regards,

Kristian

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Ensure you have a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name by the month number.  To your visual, drag Year and Month name from the Calendar Table.  Write these measures:

Sales = sum('Sales Invoice FACT'[GSV_AccountingCurrency])

Sales in past 6 months (excluding this month) = calculate([sales],datesbetween(calendar[date],edate(min(calendar[date]),-6),min(calendar[date])-1))

Measure = countrows(filter(values(Customers[Customer Name]),[Sales in past 6 months (excluding this month)]=0))

Hope this helps.


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

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Ensure you have a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name by the month number.  To your visual, drag Year and Month name from the Calendar Table.  Write these measures:

Sales = sum('Sales Invoice FACT'[GSV_AccountingCurrency])

Sales in past 6 months (excluding this month) = calculate([sales],datesbetween(calendar[date],edate(min(calendar[date]),-6),min(calendar[date])-1))

Measure = countrows(filter(values(Customers[Customer Name]),[Sales in past 6 months (excluding this month)]=0))

Hope this helps.


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

Hello Ashish,

 

Thank you for the suggestion. I have followed your recommendation step by step and this approach seems to work for the current month but not when I pull this into a table with months.

 

On the table below the total is correct but not the rows:

Kristian_nho_0-1652201291489.png

.. the number of customers with GSV = 0 in the last 6 months is 490 (not 128) for May 2022.

Is there a way how to show this data on the row level?

 

22-05 = 490

22-04 = 514

22-03 = 559

etc.

 

Kind regards,

Kristian

 

Hi,

Share the link from where i can download your PBI file.


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

Hi Ashish,

 

I have found the issue. I have set the Cross filter direction to single (from customer to sales) and that solved it.

 

Thanks a lot.

Kristian

You are welcome.


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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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