Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hobojoe720
New Member

Show customers with no order in X months

Hey all,

 

2 parts to this really; ideally I would like to have the X months selectable from a slicer. But in effect, we have a table similar to this:

+-----------+------------+----------+
| Customer  | OrderDate  | SalesRep |
+-----------+------------+----------+
| Customer1 | 2019-09-02 | John     |
+-----------+------------+----------+
| Customer2 | 2019-05-01 | Sally    |
+-----------+------------+----------+
| Customer1 | 2018-01-01 | John     |
+-----------+------------+----------+
| Customer2 | 2018-01-01 | Sally    |
+-----------+------------+----------+
| Customer3 | 2015-01-01 | Bob      |
+-----------+------------+----------+

We have a list of orders, with a date, a sales rep and a customer name. What we want to be able to do is show all customers who's latest order is older than X months. So for example, if we set the above to 3 months (today being 2019-09-02) Customer2 and Customer3 would show, with the latest order date and the SalesRep.

+-----------+------------+----------+
| Customer  | OrderDate  | SalesRep |
+-----------+------------+----------+
| Customer2 | 2019-05-01 | Sally    |
+-----------+------------+----------+
| Customer3 | 2015-01-01 | Bob      |
+-----------+------------+----------+

 

Change it to 6 months and only Customer3 would show.

+-----------+------------+----------+
| Customer  | OrderDate  | SalesRep |
+-----------+------------+----------+
| Customer3 | 2015-01-01 | Bob      |
+-----------+------------+----------+

Can anyone advise?

Thanks in advance.

 

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you so much. It helped me a lot!

Greg_Deckler
Super User
Super User

You should be able to create a measure and filter on it like this:

 

Measure = 
VAR __months = MAX('Slicer'[Value]) // get slicer value
VAR __customer = MAX([Customer]) // get current customer
VAR __table = FILTER(ALL('Table'),[Customer] = __customer)
VAR __maxDate = MAXX(__table,[OrderDate])
VAR __isInScope = IF(__maxDate >= EDATE(TODAY(),__months),1,BLANK())
RETURN
__isInScope

Something along those lines.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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