Forum Discussion

NewbieJono's avatar
NewbieJono
Post Partisan
2 years ago
Solved

Previous working date

hello, i have a date table with a marker (1,0) and I mark a working day as a 1. What do I need to do to get the previous working date.

 

For example

 

On a bank holiday weekend, on Tuesday I would like to find out Friday's date

 

i have markers of 1's for all working days

  • NewbieJonoUse the below dax code to find out previous working date :

    LastWorkingDate =
    VAR _previousDate = CALCULATE(
        MAX('date'[Date]),
        FILTER(
            ALL('date'),
            'date'[Date] < SELECTEDVALUE('date'[Date]) && NOT 'date'[Is Workday?] IN {0}
        )
    )
    RETURN
    IF(SELECTEDVALUE('date'[Is Workday?]) = 0,_previousDate) //only showing last working date for holiday, other will be blank


    Hope this help!!
    If this answered your question, please mark it as a solution!!

4 Replies

  • NewbieJonoUse the below dax code to find out previous working date :

    LastWorkingDate =
    VAR _previousDate = CALCULATE(
        MAX('date'[Date]),
        FILTER(
            ALL('date'),
            'date'[Date] < SELECTEDVALUE('date'[Date]) && NOT 'date'[Is Workday?] IN {0}
        )
    )
    RETURN
    IF(SELECTEDVALUE('date'[Is Workday?]) = 0,_previousDate) //only showing last working date for holiday, other will be blank


    Hope this help!!
    If this answered your question, please mark it as a solution!!

  • NewbieJonoUse the given code to find out last working date :

    LastWorkingDate =
    VAR _previousDate = CALCULATE(
        MAX('date'[Date]),
        FILTER(
            ALL('date'),
            'date'[Date] < SELECTEDVALUE('date'[Date]) && NOT 'date'[Is Workday?] IN {0}
        )
    )
    RETURN
    //only showing last working date for holiday, other will be blank
    IF(SELECTEDVALUE('date'[Is Workday?]) = 0,_previousDate)
     

    Hope this help🙂

    If this answered your question, please mark it as a solution!!

     
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,shafiz_p 

      Thank you for sharing, it is very helpful to our community, hope your life goes well.

       

      Best Regards,

      Leroy Lu