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

New Column in Opportunity Table for Sales Opportunities Won in last Year

I have a Sales Opportunities table where I am trying to create a new column that will show if the Account has a won opportunity in the past 365 days from the date the opportunity was created. I have a date table related to the create date column in the opportunity table. 

 

The logic for this new column is something like as follows:

 

is_new_Opp = if client has opportunity won in the last 365 days of the date the opportunity was created, then "New", else "Existing"

 

Model look like this:

PeterBlatchley_0-1700171907631.png

 

This is sample data that includes the column I am trying to create "is_new_Opp".

PeterBlatchley_1-1700173127077.png

 

 

1 ACCEPTED SOLUTION

@amitchandak ,

Thank you for your quick reply. I used your code and with one modification, it seems to be working. I had to add a filter to the VAR  "_last" to include that the opportunity needes to be won. It now reads:

 

Var _last = maxx(
    filter(prodOpportunities,
        [account_id] = earlier([account_id])  && [Opportunity_date_created] < earlier([Opportunity_date_created] ) && prodOpportunities[closed_won] = 1 )
        , [Opportunity_date_created])
return
Switch(True(),
isblank(_last), "New",
datediff(_last, [Opportunity_date_created], day) >365, "New" ,
"Existing"
)

View solution in original post

2 REPLIES 2

@amitchandak ,

Thank you for your quick reply. I used your code and with one modification, it seems to be working. I had to add a filter to the VAR  "_last" to include that the opportunity needes to be won. It now reads:

 

Var _last = maxx(
    filter(prodOpportunities,
        [account_id] = earlier([account_id])  && [Opportunity_date_created] < earlier([Opportunity_date_created] ) && prodOpportunities[closed_won] = 1 )
        , [Opportunity_date_created])
return
Switch(True(),
isblank(_last), "New",
datediff(_last, [Opportunity_date_created], day) >365, "New" ,
"Existing"
)
amitchandak
Super User
Super User

@PeterBlatchley ,

New column=

Var _last = maxx(filter(Table, [Account] = earlier([Account])  && [Opportunity_date_created] < earlier([Opportunity_date_created]) ), [Opportunity_date_created])

return

Switch(True(),

isblank(_last), "New",

datediff(_last, [Opportunity_date_created], day) >365, "New" ,

"Existing"

)

 

 

The model needs to improve, You need two copies of Prod Account. One as Fact and one dimension

 

and Fact should not join with prodopportunity

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

November Carousel

Fabric Community Update - November 2024

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

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.