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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.