cancel
Showing results 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

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.

.. 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.

Regards,

Kristian

1 ACCEPTED SOLUTION
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
5 REPLIES 5
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
Frequent Visitor

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:

.. 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

Super User

Hi,

Regards,
Ashish Mathur
http://www.ashishmathur.com
Frequent Visitor

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

Super User

You are welcome.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

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

#### Power BI Monthly Update - July 2024

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

#### Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors