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
jakeudy
Helper I
Helper I

Classifying an order based on multiple results within the order

I have a table that looks like this:

Order #Date requested byActual delivery dateitem IDQty orderedQty deliveredResult
543865/4/20205/7/2020238347347Late
543864/17/20204/16/2020192220220On time
793456/3/20206/1/20206811515On time
793456/17/20206/5/2020356110110On time
403212/17/20202/21/20209745656Late
403213/1/20202/13/20206068989On time
403214/12/20204/9/2020135200200On time

 

The "Result" column is a calculated field that determines whether the item on an order was on time or late. In most cases, an order will have multiple items on it and each item may have different delivery dates requested by the customer. I want to set up an additional column/measure that looks at the order as a whole and if one item on that order was late, then the whole order would be classified as late. Below is my desired result. What would the formula look like for that? Any help would be appreciated!

Order #Overall Result
54386Late
79345On Time
40321Late
1 ACCEPTED SOLUTION

Hi @jakeudy ,

 

I think you are talking about this:

Column =
VAR x =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Order #] ),
            'Table'[Actual delivery date] > 'Table'[Date requested by]
        )
    )
RETURN
    IF ( x > 0, "Late", "On time" )
Measure =
VAR x =
    COUNTROWS (
        FILTER ( 'Table', 'Table'[Actual delivery date] > 'Table'[Date requested by] )
    )
RETURN
    IF ( x > 0, "Late", "On time" )

1.PNG

 

For more details, please see the attachment.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@jakeudy , Try a new measure like

maxx(summarize(Table,Table[order], "_1", calculate(countrows(Table),Table[Result]= "Late")),if([_1]>=1,"Late","On-Time"))

This sort of worked, however its not quite what I'm looking for. When I view the data in table format it works correctly. However, when I try to view it in a different format such as a card or a column chart, it messes up the calculation. Ideally I would like to use this measure to see what percentage of orders are on time and what percentage are late. So I'd like to build a 100% stacked column chart with this measure as the legend, and the count (distinct) of orders as the value. Is there something I can add to the formula to accomodate this? Do I need to change it from a measure to a column? I've noticed that using a measure in the legend of a visual often does not work. Thank you for your help! @amitchandak 

Hi @jakeudy ,

 

I think you are talking about this:

Column =
VAR x =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Order #] ),
            'Table'[Actual delivery date] > 'Table'[Date requested by]
        )
    )
RETURN
    IF ( x > 0, "Late", "On time" )
Measure =
VAR x =
    COUNTROWS (
        FILTER ( 'Table', 'Table'[Actual delivery date] > 'Table'[Date requested by] )
    )
RETURN
    IF ( x > 0, "Late", "On time" )

1.PNG

 

For more details, please see the attachment.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This worked perfectly, thank you!

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.