I want to calculate the distinct count of active customers but only for the last three completed months how can I do this in DAX

0 votes

I want to calculate the distinct count of active customers but only for the last three completed months—how can I do this in DAX?
I need a DAX measure that calculates the distinct count of active customers, but it should only consider the last three fully completed months. What is the best approach using DATEADD, CALCULATE, or FILTER to ensure accurate customer count based on date filtering?

2 hours ago in Power BI by anonymous
• 18,340 points
3 views

1 answer to this question.

0 votes

To calculate the distinct count of active customers for the last three fully completed months in Power BI using DAX, follow this approach:

DAX Measure for Last 3 Completed Months' Active Customers

Active Customers (Last 3 Months) = 
VAR MaxDate = MAX( 'Date'[Date] )
VAR LastCompletedMonth = EOMONTH( MaxDate, -1 ) -- Last full month end
VAR ThreeMonthsAgo = EOMONTH( LastCompletedMonth, -2 ) -- 3 months back

RETURN 
CALCULATE( 
    DISTINCTCOUNT( 'Sales'[CustomerID] ),
    'Date'[Date] > ThreeMonthsAgo && 'Date'[Date] <= LastCompletedMonth
)

Explanation:

Discovering the Last Completed Month :

EOMONTH(MAX(Date),-1)-It gives the last day of the previous completed month.

Finding the Beginning of the 3-Month Window:

EOMONTH(LastCompletedMonth, -2)-Calculates the last day of the month that was three months ago.

Filtering the Data to the Right Range:

It uses CALCULATE() to count distinct CustomerIDs, but only within the last three completed months.

answered 2 hours ago by anonymous
• 18,340 points

Related Questions In Power BI

0 votes
1 answer

How to Calculate Total Sales for the Last 3 Months Dynamically in DAX?

To dynamically calculate total sales for the ...READ MORE

answered 6 days ago in Power BI by anonymous
• 18,340 points
32 views
0 votes
1 answer
0 votes
1 answer

In DAX, how do I RETURN the sum of a calculated column from a DAX Table Variable (created via ADDCOLUMN)?

You can access column variables of previously ...READ MORE

answered Oct 8, 2020 in Power BI by Gitika
• 65,770 points
4,720 views
0 votes
1 answer

How to measure in DAX to calculate YTD for chosen month only for Power BI?

If you use the date column from FactTable, ...READ MORE

answered Dec 22, 2020 in Power BI by Gitika
• 65,770 points
5,019 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,517 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,130 points
2,866 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,649 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Open power bi report nd sign in ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited 4 days ago 1,790 views
0 votes
1 answer

I need to calculate a running total but reset it at the start of each new quarter—how can I achieve this in DAX?

To calculate a running total that resets ...READ MORE

answered 2 days ago in Power BI by anonymous
• 18,340 points
30 views
0 votes
1 answer

I need to compute a year-over-year (YoY) growth rate but only for months where I have data in both years—how do I do this?

Calculating Year-over-Year (YoY) growth only for those ...READ MORE

answered 3 hours ago in Power BI by anonymous
• 18,340 points
3 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP