Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Nested filter context modification

Hey guys. I've stumbled on bit of a pickle. I've got a simple 'Orders' table containing list of order details specifying [Order #], [Date created], [Date closed] and [Age (days)]: The [Date c...
  • lbendlin's avatar
    2 years ago

    You could go all cute and use INTERSECT and USERELATIONSHIP

     

     

    WIP = 
    var w = max(Dates[Week])
    var cr = CALCULATETABLE(VALUES(Orders[Order #]),Dates[Date]<=w)
    var cl = CALCULATETABLE(VALUES(Orders[Order #]),Dates[Date]>w,USERELATIONSHIP(Dates[Date],Orders[Date Closed]))
    return countrows(INTERSECT(cr,cl))

     

     

    ,  or you could simply inactivate both relationships.

     

     

     

    WIP = 
    var w = max(Dates[Week])
    return CALCULATE(COUNTROWS(Orders),Orders[Date Created]<=w,Orders[Date Closed]>w)