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
Jacqee
Frequent Visitor

Max and Min by Item, status and dates

Hello,

 

I have a limited data set as an example which shows items as they go through different statuses.  I'm trying to get to who (User) worked each item (UID) from the last Assigned date to the first Passed or Failed date to determine how long it took to work each item with removing any time the item spent in an Awaiting status.

 

I started by trying to get the dates for the statuses in new columns but didn't know how to get the min & max since I only want the last Assigned date before the first Pass or Fail dates.  Then not sure how to build out removing time. 

 

Suggestions on how to do this?

 

Jacqee_0-1720618674645.png

 

5 REPLIES 5
Anonymous
Not applicable

Hi @Jacqee ,

 

Thanks for the reply from @vanessafvg .

 

First, please note the format of the Status Date column and make sure it is in Date/time format after correcting it.

 

Create two Calculation columns to calculate the last Assigned Date and the first Pass/Fail Date.

LastAssignedDate = 
CALCULATE(
    MAX('Table'[Status Date]),
    FILTER(
        'Table'.
        'Table'[UID] = EARLIER('Table'[UID]) &&
        'Table'[Status Desc] = "ASSIGNED" &&
        'Table'[Status Date] < 
            CALCULATE(
                MIN('Table'[Status Date]),
                FILTER(
                    'Table'.
                    'Table'[UID] = EARLIER('Table'[UID]) &&
                    ('Table'[Status Desc] = "PASSED" || 'Table'[Status Desc] = "FAILED")
                )
            )
    )
)

FirstPassedFailedDate = 
CALCULATE(
    MIN('Table'[Status Date]),
    FILTER(
        'Table'.
        'Table'[UID] = EARLIER('Table'[UID]) &&
        ('Table'[Status Desc] = "PASSED" || 'Table'[Status Desc] = "FAILED")
    )
)

 

Create a measure that calculates the Datediff and subtracts the wait time.

TimeTakenExcludingAwaiting = 
VAR _currentID = MAX('Table'[UID])
var _A =
CALCULATE(MAX('Table'[Status Date]),FILTER(ALLSELECTED('Table'),'Table'[Status Desc]="AWAITING CLARIFICATION"&&'Table'[UID]=_ currentID))
RETURN
IF(
    _A<>BLANK(),DATEDIFF(
    MAX('Table'[LastAssignedDate]),
    MAX('Table'[FirstPassedFailedDate]),
    DAY
)-DATEDIFF(MAX('Table'[LastAssignedDate])),_A,DAY))

 

The page visualization is shown below:

vhuijieymsft_0-1721022846230.png

 

If you have any other questions please feel free to contact me.

 

The pbix file is attached.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Also is there a way to limit the count to just one day per day.  So if the UID goes into an Awaiting status more than once per day that it only counts it once and not multiple times?

This is awesome!  How would I add in additional "Awaiting" criteria like "Awaiting Update" and "Awaiting Review"?  I'm assuming it's in the measure... but mixing the Awaiting 'or's with the && UID throws me off.

vanessafvg
Super User
Super User

can you provide the data in text format?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Thank you!

Audit IndexUIDStatusStatus DateUserStatus Desc

617777386020604/02/2024 11:29AM310575ASSIGNED
617778386020604/02/2024 11:30AM262462ASSIGNED
6178073860204704/02/2024 20:19262462WAITING ON REFRESH
618671386020404/13/202411:20262462AWAITING CLARIFICATION
6189713860202604/24/2024 8:33262462ACTING OUT
619040386020204/24/2024 14:24262462IN-PROGRESS
6191113860203004/25/2024 10:53262462DTU LEAD QUESTION
619211386020204/26/2024 13:47262462IN-PROGRESS
619331386020104/29/2024 16:41262462PASSED
618034386021604/03/2024 7:3127654ASSIGNED
618037386021604/08/2024 7:35:07AM270378ASSIGNED
618051386021604/03/2024 10:46267573ASSIGNED
6180723860214704/03/2024 13:40267578WAITING ON REFRESH
618641386021404/18/2024 9:23:17AM267573AWAITING CLARIFICATION
6190423860212604/24/2024 14:29267573ACTING OUT
619150386021204/25/2024 15:52267578IN-PROGRESS
619630386021105/02/202416:32267573PASSED
618054386022604/03/2024 10:47315575ASSIGNED
6180633860224704/03/202411:23315575WAITING ON REFRESH
618559386022704/17/2024 10:29315575QUESTION
6186043860221204/17/2024 17:3287377RETURNED
6186093860224704/13/2024 6:37315575WAITING ON REFRESH
618630386022404/18/2024 9:10:47AM315575AWAITING CLARIFICATION
6188713860222604/23/2024 8:26315575ACTING OUT
618924386022204/23/2024 14:17315575IN-PROGRESS
619144386022304/25/2024 15:05315575FAILED
6192023860221204/26/2024 12:2487877RETURNED
619209386022204/26/2024 13:04315575IN-PROGRESS
619241386022704/29/2024 7:23315575QUESTION
6193053860221204/29/2024 13:2387377RETURNED
6193073860222704/29/2024 13:37315575IN LINE TESTING
619308386022204/29/2024 13:37315575IN-PROGRESS
619368386022104/30/2024 9:35315575PASSED

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