cancel
Showing results for 
Search instead for 
Did you mean: 

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

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

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

Power BI Fabric Summit Carousel

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