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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MrFugbaum
Frequent Visitor

Return next transaction_id based on begin date

Hello there,

 

I have a matrix in Power BI that looks like this (except the yellow column):

Screenshot 2023-11-24 141447.png

 

I want to return the next transaction_id based on the begin_date_time. The yellow column is demonstrating the expected result of the measure. So the transaction with let's say ID 9 started at 8:13 AM. The next transaction in chronological order started at 8:20 AM, so ID 18.

Transactions are generated in a store and at a counter (second and third column). The matrix is filtered by three slicer: the store_id, the counter_id and the begin_date.

My current measure looks like this. I first tried to filter my transaction table to all transaction after the current one and count the rows of this table. Unfortunetally I fail trying even this:

 

 

next transaction_id = 
var _begin =  SELECTEDVALUE( 'transaction'[begin_date_time] )
var _result = CALCULATE( COUNTROWS( 'transaction' ), ALLSELECTED( 'transaction' ), 'Timetable'[Time] > _begin ) 
return _begin 

 

 

I am thankfull for every advice!

Best regards

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MrFugbaum , Try a measure like

New meausre =
var _next = minx(filter(allselected(Table), Table[store_id] = max(Table[Store_id]) && Table[begin_date_time] > max(Table[begin_date_time])),[begin_date_time])
return
minx(filter(allselected(Table), Table[store_id] = max(Table[Store_id]) && Table[begin_date_time] = _next),[transaction_id ])

 

 

If you need a new column you can use it earlier in place max and remove allselected on the table

 

Earlier, I should have known Earlier: https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@MrFugbaum , Try a measure like

New meausre =
var _next = minx(filter(allselected(Table), Table[store_id] = max(Table[Store_id]) && Table[begin_date_time] > max(Table[begin_date_time])),[begin_date_time])
return
minx(filter(allselected(Table), Table[store_id] = max(Table[Store_id]) && Table[begin_date_time] = _next),[transaction_id ])

 

 

If you need a new column you can use it earlier in place max and remove allselected on the table

 

Earlier, I should have known Earlier: https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

Works fine for me. Thank you very much!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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