Forum Discussion

rsbin's avatar
rsbin
Community Champion
4 years ago
Solved

Help with Calculated Column

Hello, Could use some guidance on accomplishing the following scenario.  Is using Earlier function the way to go?  I have a "Payroll" table containing hours worked for each day for each employee....
  • speedramps's avatar
    4 years ago

    Hi rsbin

     

    No need to use EARLIER, this is easier ....

     

    Sunday prior =

    -- get this weekdate

    VAR myweekdate = SELECTEDVALUE(payroll [weekdate])  

    --  gets the previous week

    VAR prevweekdate = DATEADD(myweekdate ,-7,day)  

    RETURN
    -- gets prior sunday by removing the week filter and then getting the previous week


    CALCULATE(payroll(Sunday),   
    ALL(payroll, payroll[weekdate]),
    payroll[weekdate] = prevweekdate)

     

    I am a Power BI volunteer. Please click the thumbs up for me going to the effort of trying to helping you. Then click solved if I fix your problem. One problem per ticket please. If you need to expand or change your problem then please raise a new ticket and click solved on this one so we get kudos. Many thanks.