Forum Discussion

wlandry12's avatar
wlandry12
Frequent Visitor
4 years ago
Solved

DAX measure for comparing MAX dates with conditional column filter

I'm not sure the title here best describes my predicament and I'm having trouble finding the right search terms, so forgive me if the solution to this is right under my nose here in the forums. I ...
  • VahidDM's avatar
    4 years ago

    Hi wlandry12 

     

    I think your result table is not correct, for example the MAX date for the cost code 165 in the DirectCosts is 25-May-22 and there are 4 lines on ShippingCalendar  table for that cost code with dates before  25-May-22.

    BTW, try this measure:

    PaidLoadQty = 
    VAR _Max_Date =
        CALCULATE (
            MAX ( DirectCosts[PaidDate] ),
            ALLEXCEPT ( DirectCosts, DirectCosts[Cost Code] )
        )
    RETURN
        CALCULATE (
            COUNTROWS ( ShippingCalendar ),
            ShippingCalendar[ApprovedDate] <= _Max_Date
        )

     

    Output:

     

     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!! 

    LinkedIn | Twitter | Blog | YouTube