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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
aJamie
Frequent Visitor

Returning a Conditional String From Next Row

Hi,

 

I'm trying to add a column to the table below to calculate the 'Next ID', based on 'Last ID' and where 'Mins' is not 0, with a reset at each Product change.

 

Any help with this would be appreciated..

 

Current:

 

ProductLast IDMins
Prod110510
Prod120520
Prod13050
Prod140515
Prod15050
Prod160520
Prod210510
Prod22050
Prod23050
Prod240530
Prod25050
Prod260520
Prod310510
Prod32050
Prod33050
Prod340525
Prod350510
Prod36050

 

Expected Output:

 

ProductLast IDMins Next ID
Prod110510 205
Prod120520 405
Prod13050 -
Prod140515 605
Prod15050 -
Prod160520 -
Prod210510 405
Prod22050 -
Prod23050 -
Prod240530 605
Prod25050 -
Prod260520 -
Prod310510 405
Prod32050 -
Prod33050 -
Prod340525 505
Prod350510 -
Prod36050 -

 

Thanks,

Jamie.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@aJamie , Create a new column like

 

minx(filter(Table, [Product] =earlier([Product]) && [Last ID] >earlier([Last ID]) && [Mins] <> 0 ), [Last ID])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
aJamie
Frequent Visitor

Amazing! ..thanks so much for your help. Perfect solution.

Tahreem24
Super User
Super User

@aJamie  Try this: 

* Make little tweak in @amitchandak DAX like below

Column 2 =
VAR a_ = MINX(FILTER(MyTable, MyTable[Product] =EARLIER(MyTable[Product]) && MyTable[Last ID]>EARLIER(MyTable[Last ID]) && MyTable[Mins] <> 0 ), MyTable[Last ID])
RETURN IF(MyTable[Mins]=0 && MIN(MyTable[Product])<MAX(MyTable[Product]),0,a_)
 
Then Create a measure like below:
Measure = IF(MAX(MyTable[Column 2])=0,"-",MIN(MyTable[Column 2]))
 
Capture.JPG
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Thanks @Tahreem24  - an excellent suggestion..

amitchandak
Super User
Super User

@aJamie , Create a new column like

 

minx(filter(Table, [Product] =earlier([Product]) && [Last ID] >earlier([Last ID]) && [Mins] <> 0 ), [Last ID])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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.