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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
makarama
Frequent Visitor

Refer to previous row based on conditions from two other columns.

I have something like this:

 

Ticket Number                    TeamStartEndColumn that I want to calculate
105    Liverpool   1-6-2023 02:33   1-6-2023 05:01   -
105   Ajax1-6-2023 05:01   1-6-2023 07:51   Liverpool - Ajax
113Ajax1-6-2023 09:01   1-6-2023 09:14   -
103Arsenal1-6-2023 07:49   1-6-2023 09:23   -
103Ajax1-6-2023 09:23   1-6-2023 09:35   Arsenal - Ajax
103Liverpool1-6-2023 09:35   1-6-2023 10:35   Ajax - Liverpool

 

This table shows the reassignment that took place for specific tickets. As you can see ticket 105 was handled by 2 teams: Liverpool and Ajax, ticket 113 only Ajax etc.

What I want, is to add a column in this table that will contain the from which and to which team the reassignment took place.

 

As you can see Liverpool handled the ticket 105 between 1-6-2023 02:33 and 1-6-2023 05:01 and then Ajax took over. So the new column that I want to add would have Liverpool - Ajax as a value. If a ticket was handled by only a single team then no need to calculate something (-). 

 

So I need a formula to calculate for the same ticket and check the timestamps to make sure we follow the correct order of the reassignment from one team to another.

 

The resulted column would look like the last column in the table (Column that I want to calculate).

The original table is way larger than this and it contains more than a thousands of tickets. So we need something that can be used for the entire table.

 

Power Query is preferred.

 

Thanks

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@makarama Not sure of how to do it in Power Query although this DAX might provide some guidance on how to do it in PQ:

Column =
  VAR __TicketNumber = [Ticket Number]
  VAR __Team = [Team]
  VAR __Start = [Start]
  VAR __PrevTeam = MAXX( FILTER( 'Table', [Ticket Number] = __TicketNumber && [End] = __Start ), [Team] )
  VAR __Result = __PrevTeam & " - " & __Team
RETURN
  __Result


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

@makarama Not sure of how to do it in Power Query although this DAX might provide some guidance on how to do it in PQ:

Column =
  VAR __TicketNumber = [Ticket Number]
  VAR __Team = [Team]
  VAR __Start = [Start]
  VAR __PrevTeam = MAXX( FILTER( 'Table', [Ticket Number] = __TicketNumber && [End] = __Start ), [Team] )
  VAR __Result = __PrevTeam & " - " & __Team
RETURN
  __Result


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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors