Forum Discussion

jessicaritch's avatar
jessicaritch
Regular Visitor
9 years ago
Solved

Previous workday from calender table

I have my data table and then my calendar table.  They are linked in relationships.  I need the preivous day data.  This data does not included weekends or holidays so that's not a big deal.  My main...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi jessicaritch,

     

    I found a better function which simple than above, perhaps you can take look at below sample.

    Logic: find the last date which has the similar weekday.

     

    Create a calculate table with base fileds:

    Table = ADDCOLUMNS(CALENDAR(DATE(2015,1,1),TODAY()),"WeekNum",WEEKNUM([Date],1),"DayOfWeek",WEEKDAY([Date],1),"Year",YEAR([Date]),"Month",FORMAT([Date],"mmmm"),"WeekDay",FORMAT([Date],"dddd"))

     

     

    Calculate column:
    Previous WeekDay = CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),[Date]<EARLIER([Date])&&[DayOfWeek]=EARLIER('Table'[DayOfWeek])))

     

     

    Regards,

    Xiaoxin Sheng