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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

How to calculate the number of active opportunities per month

Hi guys, 

 

I'm new here and I have the following scenario:

 

I use the SalesForce opportunities base and I have a calendar table. The two are related by the opportunity's closing date. (Making it clear that in the Opportunity table, the data is not repeated)

 

My structure is as follows in the Opportunity table:

 

amandaborges_0-1626725274874.png

 

I need to make a table with the months of the year and how many active opportunities per month.

 

For example: Opportunity 1 opened in January and closed in July. It has to appear active in January, February, March, April, May, June and July.

 

How can I do this? I can't solve it 😞

 

Thank you in advance!

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Anonymous,

 

This solution uses a disconnected date table SlicerDate. It does not have any relationships with other tables.

 

Measure:

 

Active Opportunities = 
VAR vMinDate =
    MIN ( SlicerDate[Date] )
VAR vMaxDate =
    MAX ( SlicerDate[Date] )
VAR vResult =
    CALCULATE (
        COUNT ( Opportunity[ID] ),
        // creation date in current month
        ( Opportunity[Creation date] >= vMinDate
            && Opportunity[Creation date] <= vMaxDate )
            // closing date in current month
            || ( Opportunity[Closing date] >= vMinDate
            && Opportunity[Closing date] <= vMaxDate )
            // creation date in earlier month and closing date in later month
            || ( Opportunity[Creation date] < vMinDate
            && Opportunity[Closing date] > vMaxDate )
    )
RETURN
    vResult

 

Create visual with SlicerDate[Month]:

 

DataInsights_0-1626807944844.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
DataInsights
Super User
Super User

@Anonymous,

 

This solution uses a disconnected date table SlicerDate. It does not have any relationships with other tables.

 

Measure:

 

Active Opportunities = 
VAR vMinDate =
    MIN ( SlicerDate[Date] )
VAR vMaxDate =
    MAX ( SlicerDate[Date] )
VAR vResult =
    CALCULATE (
        COUNT ( Opportunity[ID] ),
        // creation date in current month
        ( Opportunity[Creation date] >= vMinDate
            && Opportunity[Creation date] <= vMaxDate )
            // closing date in current month
            || ( Opportunity[Closing date] >= vMinDate
            && Opportunity[Closing date] <= vMaxDate )
            // creation date in earlier month and closing date in later month
            || ( Opportunity[Creation date] < vMinDate
            && Opportunity[Closing date] > vMaxDate )
    )
RETURN
    vResult

 

Create visual with SlicerDate[Month]:

 

DataInsights_0-1626807944844.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@DataInsights , hey! 🙂

 

Thank you for your help! This works perfectly.

 

In my structure there is already a calendar table related to several other tables. I'll create one just for this kind of situation... I hope it won't be a problem.

 

I really appreciate it 🙂 Have a nice week.

Hi Amanda,

 

Glad to hear that works. That's the correct approach--keep the main calendar table in your data model (with relationships to other tables).

 

Have a good week. 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.