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
PhillippaR
New Member

Complex query

Hi all

 

Am trying to do a query which is a little complex and beyond my capabilities. It's for CRM sales data so I have an account table and an opportunity table. The end goal is to show 'new accounts' this financial year however an account can be created long before it purchases anything. So what I want is a query that determines the date the first opprotunity was won for an account and only include those in this financial year.

 

As an account may have many opportunities, it's important to only take the first (oldest) one to see when the account became a customer.

 

I'm sure it's doable through sorting/grouping but a little unsure how to go about it. Any ideas?

 

Cheers

P

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Is this Microsoft CRM or some other CRM? Sample data is always helpful. The basic approach would be that you relate your account and opportunities and then you could create a measure that creates a count of opportunities filtered such that it only counts opportunities in the last 365 days or whatever time measure you want to use. Then, you list your accounts and filter where that count is not 0. Now you only have accounts where the opportunities closed in the last x number of days/timeline are not 0 so those are new accounts.

 

You would create a measure in the Accounts table that counts related Opportunities, if that is not clear.


@ 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...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

Is this Microsoft CRM or some other CRM? Sample data is always helpful. The basic approach would be that you relate your account and opportunities and then you could create a measure that creates a count of opportunities filtered such that it only counts opportunities in the last 365 days or whatever time measure you want to use. Then, you list your accounts and filter where that count is not 0. Now you only have accounts where the opportunities closed in the last x number of days/timeline are not 0 so those are new accounts.

 

You would create a measure in the Accounts table that counts related Opportunities, if that is not clear.


@ 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.

Top Solution Authors
Top Kudoed Authors