Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
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.
Please help.
Regards,
Kristian
Solved! Go to Solution.
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.
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.
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
Hi,
Share the link from where i can download your PBI file.
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.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.