Forum Discussion
Needs a calculation and visual for inventory items
I have an Inventory data set with multiple rows were item/ID where I need a distinct count of IDs by the first Close date after the last Open or In Progress status. I'm stumped!
Here's a sample of the data for on ID
I want to get to the Closed item highlighted in yellow. The goal is to plot the date received by column and the date Closed by line. The received seems straightforward with the LD_DT but I can't figure out how to get to the Closed row since it's not the last row but rather the first row after the last Open or In Progress row.
Thanks in advance!!!
- Anonymous1 year ago
Hi Jacqee
Thank you for reaching out to Microsoft Fabric Community Forum.I recently ran into a requirement where I needed to identify, for each item/ID, the first time a case was marked as Closed after the last time it was marked Open or In Progress. This is part of a case lifecycle/inventory tracking scenario. After experimenting with different approaches, I was able to solve it using two calculated columns in DAX. Here's a breakdown of the logic.
For each ID, return only the first Closed status that comes after the latest Open or In Progress status.
Here's what the result looks like in a table visual. You can see the correct row is flagged with a ✔ for each ID — this is the row that meets the condition.
- Column 1 (LastNonClosedDate) : Gets the last non-closed date for each ID
- Column 2 (FirstClosedAfterNonClosed) : Finds the earliest Closed status after that date
- Only that row is flagged
Attached snip shows the final table where the correct Closed row is flagged with a ✔ for each ID.
Create a caluculated colum to achive the above Solution.FirstClosedAfterNonClosed =
VAR _LastDate =CALCULATE (MAX ( 'sample_status_data'[date] ),FILTER ('sample_status_data','sample_status_data'[ID] = EARLIER ( 'sample_status_data'[ID] ) &&'sample_status_data'[Status] <> "closed"))VAR _FirstClosedDate =CALCULATE (MIN ( 'sample_status_data'[date] ),FILTER ('sample_status_data','sample_status_data'[ID] = EARLIER ( 'sample_status_data'[ID] ) && 'sample_status_data'[Status] = "closed" && 'sample_status_data'[date] > _LastDate) )RETURNIF ( 'sample_status_data'[date] = _FirstClosedDate, "✔", BLANK() )
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Regards,
Akhil. Hi Jacqee ,
I think you can try to create a measure and then use conditional formatting to achieve your goal.
Meausre:
MEASURE = VAR _LastProgressorOpen = CALCULATE ( MAX ( 'Table'[status Timestamp] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = MAX ( 'Table'[ID] ) && 'Table'[Status Catg.] in {"Open","In Progress"} ) ) VAR _Close = CALCULATE ( MIN ( 'Table'[status Timestamp] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = MAX ( 'Table'[ID] ) && 'Table'[Status Catg.] = "Closed" && 'Table'[status Timestamp] >= _LastProgressorOpen ) ) RETURN IF ( MAX ( 'Table'[status Timestamp] ) = _Close, "Yellow" )Conditional formatting:
Result is as below.
Best Regards.
Rico Zhou
8 Replies
- ryan_mayu
Super User
you can create two columns
Column =var _check= maxx(FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Status]<>"closed"&&'Table'[date]>EARLIER('Table'[date])),'Table'[date])return if (ISBLANK(_check)&&'Table'[Status]="closed","y")Column 2 = if('Table'[date]= minx(FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Column]="y"),'Table'[date]),"y") - AnonymousNot applicable
Hi Jacqee
Thank you for reaching out to Microsoft Fabric Community Forum.I recently ran into a requirement where I needed to identify, for each item/ID, the first time a case was marked as Closed after the last time it was marked Open or In Progress. This is part of a case lifecycle/inventory tracking scenario. After experimenting with different approaches, I was able to solve it using two calculated columns in DAX. Here's a breakdown of the logic.
For each ID, return only the first Closed status that comes after the latest Open or In Progress status.
Here's what the result looks like in a table visual. You can see the correct row is flagged with a ✔ for each ID — this is the row that meets the condition.
- Column 1 (LastNonClosedDate) : Gets the last non-closed date for each ID
- Column 2 (FirstClosedAfterNonClosed) : Finds the earliest Closed status after that date
- Only that row is flagged
Attached snip shows the final table where the correct Closed row is flagged with a ✔ for each ID.
Create a caluculated colum to achive the above Solution.FirstClosedAfterNonClosed =
VAR _LastDate =CALCULATE (MAX ( 'sample_status_data'[date] ),FILTER ('sample_status_data','sample_status_data'[ID] = EARLIER ( 'sample_status_data'[ID] ) &&'sample_status_data'[Status] <> "closed"))VAR _FirstClosedDate =CALCULATE (MIN ( 'sample_status_data'[date] ),FILTER ('sample_status_data','sample_status_data'[ID] = EARLIER ( 'sample_status_data'[ID] ) && 'sample_status_data'[Status] = "closed" && 'sample_status_data'[date] > _LastDate) )RETURNIF ( 'sample_status_data'[date] = _FirstClosedDate, "✔", BLANK() )
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Regards,
Akhil. - RicoZhouFrequent Visitor
Hi Jacqee ,
I think you can try to create a measure and then use conditional formatting to achieve your goal.
Meausre:
MEASURE = VAR _LastProgressorOpen = CALCULATE ( MAX ( 'Table'[status Timestamp] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = MAX ( 'Table'[ID] ) && 'Table'[Status Catg.] in {"Open","In Progress"} ) ) VAR _Close = CALCULATE ( MIN ( 'Table'[status Timestamp] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = MAX ( 'Table'[ID] ) && 'Table'[Status Catg.] = "Closed" && 'Table'[status Timestamp] >= _LastProgressorOpen ) ) RETURN IF ( MAX ( 'Table'[status Timestamp] ) = _Close, "Yellow" )Conditional formatting:
Result is as below.
Best Regards.
Rico Zhou
- AnonymousNot applicable
Hi Jacqee
Just checking in to see if the solution we shared worked for you? If you're still facing any issues or need more help, feel free to let us know, we're happy to assist further.
If the response helped resolve your issue, please consider marking it as Accepted as Solution and give it a thumbs up if you found it helpful.
Thanks,
Akhil. - AnonymousNot applicable
Hi Jacqee
Just checking in to see if the approach shared above helped with you in calculation and visual for inventory items?
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily. Looking forward to your update.Best regards,
Akhil - AnonymousNot applicable
Hi Jacqee
Just checking in one last time. Were you able to try out any of the suggestions shared earlier? If your issue is resolved, marking the accepted solution would be a big help to others who might be facing the same scenario.
If you went in a different direction or still need support, feel free to drop a quick update, we’re happy to keep helping.
Regards,
Akhil. - Jacqee
Helper I
Thank you for all of your input. I took a little bit for all of the suggestions unfortunately due to the amount of data I've been side tracked to make it fully work.
- AnonymousNot applicable
Hi Jacqee
Totally understand how overwhelming it can get when working with a large volume of data.
Just wanted to check in one last time if you do get a chance to revisit this and need any help trying for the final part, feel free reach out to Microsoft Fabric Community Forum, We’re happy to support you whenever you're ready.
Thanks again for keeping us updated all the best with your progress.
If you found above solutions worked for you please make a kudos and making as a solution accepeted.
Regards,
Akhil.