Forum Discussion

New_be's avatar
New_be
Helper V
5 years ago
Solved

Yesterday value: Multiple conditions

Hi everyone, i've been in a quite difficult situation right now. Having problems to get yesterday (YDA) value based on multiple conditions. It is quite hard to explain, but i will try my best so that...
  • amitchandak's avatar
    5 years ago

    New_be , I have a blog on how to work with working days that can help

     

    You need few columns out of these add, as per need in your date table

    Work Day = if(WEEKDAY([Date],2)>=6,0,1)
    Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])
    Work Date Cont = if([Work Day]=0,maxx(FILTER('Date',[Date]<EARLIER([Date]) && [Work Day]<> EARLIER([Work Day]) ),[Date]),[Date])
    Work Date cont Rank = RANKX(ALL('Date'),[Work Date Cont],,ASC,Dense)
    Work day of month = Sumx(filter(Date, [Month year] = earlier([Month Day])),[Work Day])
    Work day of week = Sumx(filter(Date, [Weekyear] = earlier([Weekyear])),[Work Day])
    
    Month Work day= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank]) && 'Date'[Work day of month]  <= Max('Date'[Work day of month]) ))
    last Month Work day= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1  && 'Date'[Work day of month]  <= Max('Date'[Work day of month]) ))
    Week till work day= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank]) && 'Date'[Work day of week]  <= Max('Date'[Work day of week])))
    last Week till work day= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1 && 'Date'[Work day of week]  <= Max('Date'[Work day of week])))
    
    

     

    try measure like

    This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Work Date cont Rank]=max('Date'[Work Date cont Rank])))
    Last work day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Work Date cont Rank]=max('Date'[Work Date cont Rank])-1))
    diff =[This Day] - [Last work day]

     

    Traveling Across Workdays - What is next/previous Working day
    https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calendar-4-5-Power/ba-p/1187766