Forum Discussion

EnrichedUser's avatar
EnrichedUser
Icon for Helper III rankHelper III
5 years ago
Solved

Max Date Minus X Days

Hi,

 

I am hoping this is a fairly easy one and that I am missing something simple.

 

Goal: Evaluate up to the selected date minus 2 days. 

I have two tables, one is a date table "Date" and the other is "SalesOrders"

I have the dax messures:

Picking Backlog =
IF(ISBLANK( [Picks Needed]),
BLANK(),
CALCULATE( [Picks Needed],
FILTER( ALLSELECTED('Date'),
'Date'[Date] <= MAX('Date'[Date]))))

and

Picks Needed =
CALCULATE(COUNT(SalesOrders[Status]), SalesOrders[Status] = "OPEN", SalesOrders[OrderStatus] <> "R")

My goal is use the Picking Backlog Messure but instead of counting to MAX('Date'[Date]), I want to count to the Max Date minus X days. Where X will be 2 for now. 
 
Example:

PickingBacklog
3/2 = 300
3/3 = 340
3/4 = 395
 
Exepected Outcome 
PickingBacklog2days = 300
One Number, Card Visual 
 -----------
Notes

I have tried using the date add function, but the limitation of Max being assest on a column has made it difficult. 
Sample Sales Order Data
BranchID    Date   SalesOrderID     Line Number   Status   Total Price
A3/3S1001Open100
A3/4S1001Open200
B3/3S1021Open300
B3/3S1032Closed400
C3/4S1041Open500
C3/2S1051Closed600
  • Hi EnrichedUser 

    Deduct 2 from the Max Date e.g.

     

    Picking Backlog =
    IF(ISBLANK( [Picks Needed]),
    BLANK(),
    CALCULATE( [Picks Needed],
    FILTER( ALLSELECTED('Date'),
    'Date'[Date] <= (MAX('Date'[Date]) - 2) )))

     

    Regards

    Phil

2 Replies

  • Hi EnrichedUser 

    Deduct 2 from the Max Date e.g.

     

    Picking Backlog =
    IF(ISBLANK( [Picks Needed]),
    BLANK(),
    CALCULATE( [Picks Needed],
    FILTER( ALLSELECTED('Date'),
    'Date'[Date] <= (MAX('Date'[Date]) - 2) )))

     

    Regards

    Phil

    • EnrichedUser's avatar
      EnrichedUser
      Icon for Helper III rankHelper III

      I am sure I tried this and variations of this multiple times before posting this...

      thank you