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
bunny53
New Member

Getting rows with the same value

Hi, I need some help with getting a final status per each ID. The table is sorted by time, and IDs are composed of random alphabets and numbers. Currently a final status is in a string format like below. I created a look up table for each status, converting each status to a numerical value as I wished to be prioritized. What I want is, if operations for an ID has at least one "Complete", I want the table to say "yes", and otherwise(no Complete at all) "no". For example of ID "K304R" below, it operated three times with Status of "Completed", "Error", and "Canceled", and thus the result I want would be a "yes".

 

My intuition was 1) ALLEXCEPT original table with ID and Status, 2) somehow get rows with the same ID(ex "K304R"), 3) somehow get Status for each rows of "K304R", 4) somehow connect Status back to the look up table, 4) get Max value for statuses, 5) return "yes" if the max value is 100, and otherwise "no".

 

Any help would be really appreciated. Thanks ahead!

 

OriginalTable

TimeIDStatus
2022/10/4 10:47AM1ZT56Error
2022/10/4 9:47AMK304RCompleted
2022/10/4 7:47AMK304RCanceled
2022/10/3 10:47PM1ZT56Completed
2022/10/3 7:47AMPQ534Canceled
2022/10/3 4:47AM12PT3Error
2022/10/2 10:40PM12PT3Error
2022/10/2 7:47PM1ZT56Canceled
2022/10/1 10:47AMU73RLCompleted

 

LookupTable

StatusStatusVal
Completed100
Canceled0
Error0

 

Result I want

TimeIDStatusFinalStatus
2022/10/4 10:47AM1ZT56Erroryes
2022/10/4 9:47AMK304RCompletedyes
2022/10/4 7:47AMK304RCanceledyes
2022/10/3 10:47PM1ZT56Completedyes
2022/10/3 7:47AMPQ534Canceledno
2022/10/3 4:47AM12PT3Errorno
2022/10/2 10:40PM12PT3Errorno
2022/10/2 7:47PM1ZT56Canceledyes
2022/10/1 10:47AMU73RLCompletedyes
1 ACCEPTED SOLUTION
MarkLaf
Solution Sage
Solution Sage

Are you actually looking to leverage LookupTable for other reasons or is its only use to try to get the correct FinalStatus output?

 

It's actually easier to do this without a helper table. You were on the right track with ALLEXCEPT, but can skip a bunch of the steps you were envisioning by using CONTAINS:

FinalStatus =
CALCULATE(
    IF(
        CONTAINS( OriginalTable, OriginalTable[Status], "Completed" ),
        "yes",
        "no"
    ),
    ALLEXCEPT( OriginalTable, OriginalTable[ID] )
)

View solution in original post

1 REPLY 1
MarkLaf
Solution Sage
Solution Sage

Are you actually looking to leverage LookupTable for other reasons or is its only use to try to get the correct FinalStatus output?

 

It's actually easier to do this without a helper table. You were on the right track with ALLEXCEPT, but can skip a bunch of the steps you were envisioning by using CONTAINS:

FinalStatus =
CALCULATE(
    IF(
        CONTAINS( OriginalTable, OriginalTable[Status], "Completed" ),
        "yes",
        "no"
    ),
    ALLEXCEPT( OriginalTable, OriginalTable[ID] )
)

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.

Top Solution Authors