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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nijos
Frequent Visitor

Calculated column to find lowest date with a filter on status value per ordernumber

I have this table with date, status and ordernumber.

 

DateStatusOrderNumber
01/01/2024101000
01/02/2024201000
01/03/2024301000
01/04/2024301000
01/05/2024401000
01/06/2024501000
01/01/2025101100
01/02/2025201100
01/06/2025301100
01/04/2025301100
01/05/2025301100
01/06/2025501100

 

For each OrderNumber, I want to find the first date that is on a row with status 30.

In a calculated column, that row must get a 1, the other rows should get a 0.

 

DateStatusOrderNumberCalculated Column
01/01/20241010000
01/02/20242010000
01/03/20243010001
01/04/20243010000
01/05/20244010000
01/06/20245010000
01/01/20251011000
01/02/20252011000
01/06/20253011000
01/04/20253011001
01/05/20253011000
01/06/20255011000

 

Thank you for your help on this.

1 ACCEPTED SOLUTION
nijos
Frequent Visitor

Calculated Column =
VAR CurrentOrder = 'Table'[OrderNumber]
VAR FilteredTable =
    FILTER ( 'Table', 'Table'[Status] = 30 && 'Table'[OrderNumber] = CurrentOrder )
VAR Result =
    CALCULATE ( MIN ( 'Table'[Date] ), FilteredTable )
RETURN
    IF ( Result = 'Table'[Date], 1, 0 )

View solution in original post

1 REPLY 1
nijos
Frequent Visitor

Calculated Column =
VAR CurrentOrder = 'Table'[OrderNumber]
VAR FilteredTable =
    FILTER ( 'Table', 'Table'[Status] = 30 && 'Table'[OrderNumber] = CurrentOrder )
VAR Result =
    CALCULATE ( MIN ( 'Table'[Date] ), FilteredTable )
RETURN
    IF ( Result = 'Table'[Date], 1, 0 )

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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