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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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