Forum Discussion

michaelho's avatar
michaelho
Frequent Visitor
3 years ago
Solved

Find distinct order count and make some negative

I have a table of sales data where each line is a line item from an order:

 

I'm trying to get a distinct order count (since there can be multiple lines per order) BUT I want to change the Return orders to a negative number so the end result looks something like this:

 

 

Any thoughts how this might be accomplished?

 

 

  • Hi michaelho 

     

    Try this:

    Distinct Order Count =
    DISTINCTCOUNT ( 'Table'[Order] )
        - CALCULATE (
            DISTINCTCOUNT ( 'Table'[Order] ),
            FILTER ( 'Table', 'Table'[Order Type] = "Returns" )
        )
    

2 Replies

  • Hi michaelho 

     

    Try this:

    Distinct Order Count =
    DISTINCTCOUNT ( 'Table'[Order] )
        - CALCULATE (
            DISTINCTCOUNT ( 'Table'[Order] ),
            FILTER ( 'Table', 'Table'[Order Type] = "Returns" )
        )
    
  • michaelho's avatar
    michaelho
    Frequent Visitor

    Thank you, danextian. That wasn't exactly what I was looking for, but I realize that this is probably a better solution.