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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Omelei
Frequent Visitor

Create new column with previous ID

Hi 

 

I've created the following table. 

 

Account IDOpp IDPrevious Opp IDStartdateRevenueCustom Previous Opportunity ID
100000006AAA006AAB1-1-2023 € 250.000 
100000006AAB006AAC1-10-2022 € 220.000 
100000006AAC 1-1-2022 € 200.000 
100001006ABA006ABB3-1-2023 € 1.000.000 
100001006ABB 1-1-2023 € 1.500.000006ABC
100001006ABC 1-1-2022 € 1.000.000006ABD
100001006ABD 1-1-2021 € 800.000 

 

 

In the Happy flow the previous opportunity id is automatically filled. However, in some cases it is not. If the previous opportunity ID is not known, I'd like to define it by searching for the Opportunity ID of the Account with the most recent Agreement start date. 

 

Please take into account the oldest opportunity of the account should not contain a previous opportunity id.

 

Hope you can help. 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Omelei 

 

try to add the column with this:

Custom Previous Opportunity ID 2 = 
VAR _id = [Account ID]
VAR _date = [Startdate]
VAR _table =
FILTER(
    data,
    data[Account ID] = _id
)
VAR _date1=
MAXX(
    FILTER(
        _table,
         data[Startdate]<_date
    ),
    data[Startdate]
)
RETURN
MAXX(
    FILTER(
       _table,
        data[Startdate] = _date1
    ),
    data[Opp ID]
)

 

it shall work like this:

FreemanZ_0-1672222420801.png

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

hi @Omelei 

 

try to add the column with this:

Custom Previous Opportunity ID 2 = 
VAR _id = [Account ID]
VAR _date = [Startdate]
VAR _table =
FILTER(
    data,
    data[Account ID] = _id
)
VAR _date1=
MAXX(
    FILTER(
        _table,
         data[Startdate]<_date
    ),
    data[Startdate]
)
RETURN
MAXX(
    FILTER(
       _table,
        data[Startdate] = _date1
    ),
    data[Opp ID]
)

 

it shall work like this:

FreemanZ_0-1672222420801.png

Omelei
Frequent Visitor

Thank you @amitchandak 

Unfortunately it throws a syntax error for RETURN. Any idea?

amitchandak
Super User
Super User

@Omelei , Create a new column like

 

Var Max = maxx(filter(Table, Table[Account ID] = earlier([Account ID]) && [Start Date] < earlier([Start Date]) ) ,[Start Date])

return

maxx(filter(Table, Table[Account ID] = earlier([Account ID]) && [Start Date] =_max ) ,[Opp ID])

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.