Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

quantity after filtered firstdate

HI,   maybe simple, but i'm through,   A customer has the choice to order (orderwy) by EDI or FAX. Now i want to know how many FAX orders are placed after the first time they ordered by EDI (by ...
  • Mariusz's avatar
    6 years ago

    Hi Anonymous 

     

    Maby someone can come up with less complicated syntax but until then you can try this, also see the attached.

     

    Measure = 
    VAR __EDIOrders =
        CALCULATETABLE(
            GROUPBY(
                Orders,
                Orders[CustomerID],
                "@MaxDate", MINX( CURRENTGROUP(), Orders[Date] )
            ),
        ALL( Orders ),
        VALUES( Orders[CustomerID] ),
        KEEPFILTERS( Orders[OrderWay] = "EDI" )
        )
    RETURN 
       SUMX(
           __EDIOrders,
           VAR __maxDate = [@MaxDate]
           RETURN 
           CALCULATE(
               COUNTROWS( Orders ),
               KEEPFILTERS( Orders[OrderWay] = "fax" ),
               KEEPFILTERS( Orders[Date] > __maxDate )
           )
        )

     

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    LinkedIn