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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Community Champion
Community Champion

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.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

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.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.