cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors